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,8 +8,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const objectSubsystem = "object"
|
||||
|
||||
type ObjectServiceMetrics interface {
|
||||
AddRequestDuration(method string, d time.Duration, success bool)
|
||||
AddPayloadSize(method string, size int)
|
||||
|
@ -20,14 +18,6 @@ type objectServiceMetrics struct {
|
|||
payloadCounter *prometheus.CounterVec
|
||||
}
|
||||
|
||||
const (
|
||||
shardIDLabelKey = "shard"
|
||||
counterTypeLabelKey = "type"
|
||||
containerIDLabelKey = "cid"
|
||||
methodLabelKey = "method"
|
||||
successLabelKey = "success"
|
||||
)
|
||||
|
||||
func newObjectServiceMetrics() *objectServiceMetrics {
|
||||
return &objectServiceMetrics{
|
||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
|
@ -35,25 +25,25 @@ func newObjectServiceMetrics() *objectServiceMetrics {
|
|||
Subsystem: objectSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Object Service request process duration",
|
||||
}, []string{methodLabelKey, successLabelKey}),
|
||||
}, []string{methodLabel, successLabel}),
|
||||
payloadCounter: metrics.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: objectSubsystem,
|
||||
Name: "request_payload_bytes",
|
||||
Help: "Object Service request payload",
|
||||
}, []string{methodLabelKey}),
|
||||
}, []string{methodLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *objectServiceMetrics) AddRequestDuration(method string, d time.Duration, success bool) {
|
||||
m.methodDuration.With(prometheus.Labels{
|
||||
methodLabelKey: method,
|
||||
successLabelKey: strconv.FormatBool(success),
|
||||
methodLabel: method,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *objectServiceMetrics) AddPayloadSize(method string, size int) {
|
||||
m.payloadCounter.With(prometheus.Labels{
|
||||
methodLabelKey: method,
|
||||
methodLabel: method,
|
||||
}).Add(float64(size))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue