frostfs-node/pkg/metrics/replicator.go

57 lines
1.5 KiB
Go
Raw Normal View History

package metrics
import (
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
"github.com/prometheus/client_golang/prometheus"
)
const replicatorSubsystem = "replicator"
type replicatorMetrics struct {
inFlightRequests prometheus.Gauge
processedObjects prometheus.Counter
totalReplicatedPayloadSize prometheus.Counter
}
func (m replicatorMetrics) IncInFlightRequest() {
m.inFlightRequests.Inc()
}
func (m replicatorMetrics) DecInFlightRequest() {
m.inFlightRequests.Dec()
}
func (m replicatorMetrics) IncProcessedObjects() {
m.processedObjects.Inc()
}
func (m replicatorMetrics) AddPayloadSize(size int64) {
m.totalReplicatedPayloadSize.Add(float64(size))
}
func newReplicatorMetrics() replicatorMetrics {
return replicatorMetrics{
inFlightRequests: newReplicatorGauge("in_flight_requests", "Number of in-flight requests"),
processedObjects: newReplicatorCounter("processed_objects", "Number of objects processed since the node startup"),
totalReplicatedPayloadSize: newReplicatorCounter("total_replicated_payload_size", "Total size of payloads replicated"),
}
}
func newReplicatorCounter(name, help string) prometheus.Counter {
return metrics.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: replicatorSubsystem,
Name: name,
Help: help,
})
}
func newReplicatorGauge(name, help string) prometheus.Gauge {
return metrics.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: replicatorSubsystem,
Name: name,
Help: help,
})
}