package metrics import ( "strconv" "time" "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics" "github.com/prometheus/client_golang/prometheus" ) type ObjectServiceMetrics interface { AddRequestDuration(method string, d time.Duration, success bool) AddPayloadSize(method string, size int) } type objectServiceMetrics struct { methodDuration *prometheus.HistogramVec payloadCounter *prometheus.CounterVec } func newObjectServiceMetrics() *objectServiceMetrics { return &objectServiceMetrics{ methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{ Namespace: namespace, Subsystem: objectSubsystem, Name: "request_duration_seconds", Help: "Object Service request process duration", }, []string{methodLabel, successLabel}), payloadCounter: metrics.NewCounterVec(prometheus.CounterOpts{ Namespace: namespace, Subsystem: objectSubsystem, Name: "request_payload_bytes", Help: "Object Service request payload", }, []string{methodLabel}), } } func (m *objectServiceMetrics) AddRequestDuration(method string, d time.Duration, success bool) { m.methodDuration.With(prometheus.Labels{ methodLabel: method, successLabel: strconv.FormatBool(success), }).Observe(d.Seconds()) } func (m *objectServiceMetrics) AddPayloadSize(method string, size int) { m.payloadCounter.With(prometheus.Labels{ methodLabel: method, }).Add(float64(size)) }