forked from TrueCloudLab/frostfs-node
[#373] metrics: Move labels to consts
To unify label naming all lable keys and other consts are moved to one file. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
b5d9f4a285
commit
03aa210145
13 changed files with 119 additions and 160 deletions
|
@ -8,12 +8,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
mcSubsystem = "morphcache"
|
||||
mcSuccess = "success"
|
||||
mcMethod = "method"
|
||||
)
|
||||
|
||||
type MorphCacheMetrics interface {
|
||||
AddMethodDuration(method string, success bool, d time.Duration)
|
||||
}
|
||||
|
@ -32,18 +26,18 @@ func newMorphCacheMetrics(ns string) *morphCacheMetrics {
|
|||
return &morphCacheMetrics{
|
||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: ns,
|
||||
Subsystem: mcSubsystem,
|
||||
Subsystem: morphCacheSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Morph cache request process duration",
|
||||
}, []string{mcSuccess, mcMethod}),
|
||||
}, []string{successLabel, methodLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *morphCacheMetrics) AddMethodDuration(method string, success bool, d time.Duration) {
|
||||
m.methodDuration.With(
|
||||
prometheus.Labels{
|
||||
mcSuccess: strconv.FormatBool(success),
|
||||
mcMethod: method,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
methodLabel: method,
|
||||
},
|
||||
).Observe(d.Seconds())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue