1
0
mirror of https://github.com/rancher/norman.git synced 2025-07-13 07:05:48 +00:00
norman/metrics/generic_controller.go
2019-11-18 09:16:05 -08:00

48 lines
1.1 KiB
Go

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