2018-09-30 06:18:00 +00:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-09-30 22:07:34 +00:00
|
|
|
TotalHandlerExecution = prometheus.NewCounterVec(
|
2018-09-30 06:18:00 +00:00
|
|
|
prometheus.CounterOpts{
|
|
|
|
Subsystem: "norman_generic_controller",
|
|
|
|
Name: "total_handler_execution",
|
2019-09-30 22:07:34 +00:00
|
|
|
Help: "Total count of hanlder executions",
|
2018-09-30 06:18:00 +00:00
|
|
|
},
|
|
|
|
[]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",
|
2018-09-30 06:18:00 +00:00
|
|
|
},
|
|
|
|
[]string{"name", "handlerName", "key"},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
func IncTotalHandlerExecution(controllerName, handlerName string) {
|
2019-09-30 22:07:34 +00:00
|
|
|
if prometheusMetrics {
|
2018-09-30 06:18:00 +00:00
|
|
|
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 {
|
2018-09-30 06:18:00 +00:00
|
|
|
TotalHandlerFailure.With(
|
|
|
|
prometheus.Labels{
|
|
|
|
"name": controllerName,
|
|
|
|
"handlerName": handlerName,
|
|
|
|
"key": key,
|
|
|
|
},
|
|
|
|
).Inc()
|
|
|
|
}
|
|
|
|
}
|