1
0
mirror of https://github.com/rancher/norman.git synced 2025-07-13 15:15:46 +00:00
norman/metrics/generic_controller.go

48 lines
1.1 KiB
Go
Raw Normal View History

package metrics
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
2019-09-30 22:07:34 +00:00
TotalHandlerExecution = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: "norman_generic_controller",
Name: "total_handler_execution",
2019-09-30 22:07:34 +00:00
Help: "Total count of hanlder executions",
},
[]string{"name", "handlerName"},
)
TotalHandlerFailure = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: "norman_generic_controller",
Name: "total_handler_failure",
2019-09-30 22:07:34 +00:00
Help: "Total count of handler failures",
},
[]string{"name", "handlerName", "key"},
)
)
func IncTotalHandlerExecution(controllerName, handlerName string) {
2019-09-30 22:07:34 +00:00
if prometheusMetrics {
TotalHandlerExecution.With(
prometheus.Labels{
"name": controllerName,
"handlerName": handlerName},
).Inc()
}
}
func IncTotalHandlerFailure(controllerName, handlerName, key string) {
2019-09-30 22:07:34 +00:00
if prometheusMetrics {
TotalHandlerFailure.With(
prometheus.Labels{
"name": controllerName,
"handlerName": handlerName,
"key": key,
},
).Inc()
}
}