frostfs-node/pkg/metrics/replicator.go
Dmitrii Stepanov c348ae35b0 [#424] metrics: Drop embedded metrics
It was not obvious where metrics are used.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-06-14 14:53:32 +03:00

65 lines
1.7 KiB
Go

package metrics
import (
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
"github.com/prometheus/client_golang/prometheus"
)
const replicatorSubsystem = "replicator"
//TODO
type ReplicatorMetrics interface {
IncInFlightRequest()
DecInFlightRequest()
IncProcessedObjects()
AddPayloadSize(size int64)
}
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,
})
}