frostfs-node/pkg/metrics/shard.go
Dmitrii Stepanov 4fcc81c999
All checks were successful
ci/woodpecker/pr/pre-commit Pipeline was successful
[#232] shard: Add PUT metrics
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-04-10 15:43:25 +03:00

30 lines
771 B
Go

package metrics
import (
"time"
"github.com/prometheus/client_golang/prometheus"
)
type shardMetrics struct {
shardOperationDuration *prometheus.HistogramVec
}
func newShardMetrics() shardMetrics {
return shardMetrics{
shardOperationDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: "shard",
Name: "operation_duration_seconds",
Help: "Accumulated shard operations duration",
}, []string{"id", "operation"}),
}
}
func (s *shardMetrics) register() {
prometheus.MustRegister(s.shardOperationDuration)
}
func (s *shardMetrics) AddShardOperationDuration(shardID string, operation string, d time.Duration) {
s.shardOperationDuration.WithLabelValues(shardID, operation).Observe(d.Seconds())
}