All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m4s
Pre-commit hooks / Pre-commit (push) Successful in 1m21s
Build / Build Components (push) Successful in 1m54s
Tests and linters / Run gofumpt (push) Successful in 3m2s
Tests and linters / Tests (push) Successful in 3m11s
Tests and linters / Lint (push) Successful in 3m29s
Tests and linters / gopls check (push) Successful in 3m31s
Tests and linters / Staticcheck (push) Successful in 3m25s
Tests and linters / Tests with -race (push) Successful in 4m18s
OCI image / Build container images (push) Successful in 4m53s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
79 lines
2.5 KiB
Go
79 lines
2.5 KiB
Go
package metrics
|
|
|
|
import (
|
|
"strconv"
|
|
"time"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
type TreeMetricsRegister interface {
|
|
AddReplicateTaskDuration(time.Duration, bool)
|
|
AddReplicateWaitDuration(time.Duration, bool)
|
|
AddSyncDuration(time.Duration, bool)
|
|
AddOperation(string, string)
|
|
}
|
|
|
|
type treeServiceMetrics struct {
|
|
replicateTaskDuration *prometheus.HistogramVec
|
|
replicateWaitDuration *prometheus.HistogramVec
|
|
syncOpDuration *prometheus.HistogramVec
|
|
ioTagOpsCounter *prometheus.CounterVec
|
|
}
|
|
|
|
var _ TreeMetricsRegister = (*treeServiceMetrics)(nil)
|
|
|
|
func newTreeServiceMetrics() *treeServiceMetrics {
|
|
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{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{successLabel}),
|
|
syncOpDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: namespace,
|
|
Subsystem: treeServiceSubsystem,
|
|
Name: "sync_duration_seconds",
|
|
Help: "Duration of synchronization operations",
|
|
}, []string{successLabel}),
|
|
ioTagOpsCounter: metrics.NewCounterVec(prometheus.CounterOpts{
|
|
Namespace: namespace,
|
|
Subsystem: treeServiceSubsystem,
|
|
Name: "requests_total",
|
|
Help: "Count of requests for each IO tag",
|
|
}, []string{methodLabel, ioTagLabel}),
|
|
}
|
|
}
|
|
|
|
func (m *treeServiceMetrics) AddReplicateTaskDuration(d time.Duration, success bool) {
|
|
m.replicateTaskDuration.With(prometheus.Labels{
|
|
successLabel: strconv.FormatBool(success),
|
|
}).Observe(d.Seconds())
|
|
}
|
|
|
|
func (m *treeServiceMetrics) AddReplicateWaitDuration(d time.Duration, success bool) {
|
|
m.replicateWaitDuration.With(prometheus.Labels{
|
|
successLabel: strconv.FormatBool(success),
|
|
}).Observe(d.Seconds())
|
|
}
|
|
|
|
func (m *treeServiceMetrics) AddSyncDuration(d time.Duration, success bool) {
|
|
m.syncOpDuration.With(prometheus.Labels{
|
|
successLabel: strconv.FormatBool(success),
|
|
}).Observe(d.Seconds())
|
|
}
|
|
|
|
func (m *treeServiceMetrics) AddOperation(op string, ioTag string) {
|
|
m.ioTagOpsCounter.With(prometheus.Labels{
|
|
ioTagLabel: ioTag,
|
|
methodLabel: op,
|
|
}).Inc()
|
|
}
|