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 treeServiceLabelSuccess = "success"
|
||||
|
||||
type TreeMetricsRegister interface {
|
||||
AddReplicateTaskDuration(time.Duration, bool)
|
||||
AddReplicateWaitDuration(time.Duration, bool)
|
||||
|
@ -25,43 +23,42 @@ type treeServiceMetrics struct {
|
|||
var _ TreeMetricsRegister = (*treeServiceMetrics)(nil)
|
||||
|
||||
func newTreeServiceMetrics() *treeServiceMetrics {
|
||||
const treeServiceSubsystem = "treeservice"
|
||||
return &treeServiceMetrics{
|
||||
replicateTaskDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: treeServiceSubsystem,
|
||||
Name: "replicate_task_duration_seconds",
|
||||
Help: "Duration of individual replication tasks executed as part of replication loops",
|
||||
}, []string{treeServiceLabelSuccess}),
|
||||
}, []string{successLabel}),
|
||||
replicateWaitDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: treeServiceSubsystem,
|
||||
Name: "replicate_wait_duration_seconds",
|
||||
Help: "Duration of overall waiting time for replication loops",
|
||||
}, []string{treeServiceLabelSuccess}),
|
||||
}, []string{successLabel}),
|
||||
syncOpDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: treeServiceSubsystem,
|
||||
Name: "sync_duration_seconds",
|
||||
Help: "Duration of synchronization operations",
|
||||
}, []string{treeServiceLabelSuccess}),
|
||||
}, []string{successLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *treeServiceMetrics) AddReplicateTaskDuration(d time.Duration, success bool) {
|
||||
m.replicateTaskDuration.With(prometheus.Labels{
|
||||
treeServiceLabelSuccess: strconv.FormatBool(success),
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *treeServiceMetrics) AddReplicateWaitDuration(d time.Duration, success bool) {
|
||||
m.replicateWaitDuration.With(prometheus.Labels{
|
||||
treeServiceLabelSuccess: strconv.FormatBool(success),
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *treeServiceMetrics) AddSyncDuration(d time.Duration, success bool) {
|
||||
m.syncOpDuration.With(prometheus.Labels{
|
||||
treeServiceLabelSuccess: strconv.FormatBool(success),
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue