2023-05-12 08:44:21 +00:00
|
|
|
package metrics
|
|
|
|
|
2023-05-31 09:25:32 +00:00
|
|
|
import (
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
2023-05-12 08:44:21 +00:00
|
|
|
|
|
|
|
const replicatorSubsystem = "replicator"
|
|
|
|
|
|
|
|
type replicatorMetrics struct {
|
2023-05-31 09:25:32 +00:00
|
|
|
inFlightRequests prometheus.Gauge
|
|
|
|
processedObjects prometheus.Counter
|
|
|
|
totalReplicatedPayloadSize prometheus.Counter
|
2023-05-12 08:44:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m replicatorMetrics) IncInFlightRequest() {
|
2023-05-31 09:25:32 +00:00
|
|
|
m.inFlightRequests.Inc()
|
2023-05-12 08:44:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m replicatorMetrics) DecInFlightRequest() {
|
2023-05-31 09:25:32 +00:00
|
|
|
m.inFlightRequests.Dec()
|
2023-05-12 08:44:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m replicatorMetrics) IncProcessedObjects() {
|
2023-05-31 09:25:32 +00:00
|
|
|
m.processedObjects.Inc()
|
2023-05-12 08:44:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m replicatorMetrics) AddPayloadSize(size int64) {
|
2023-05-31 09:25:32 +00:00
|
|
|
m.totalReplicatedPayloadSize.Add(float64(size))
|
2023-05-12 08:44:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-31 09:25:32 +00:00
|
|
|
func newReplicatorCounter(name, help string) prometheus.Counter {
|
|
|
|
return metrics.NewCounter(prometheus.CounterOpts{
|
2023-05-12 08:44:21 +00:00
|
|
|
Namespace: namespace,
|
|
|
|
Subsystem: replicatorSubsystem,
|
|
|
|
Name: name,
|
|
|
|
Help: help,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-05-31 09:25:32 +00:00
|
|
|
func newReplicatorGauge(name, help string) prometheus.Gauge {
|
|
|
|
return metrics.NewGauge(prometheus.GaugeOpts{
|
2023-05-12 08:44:21 +00:00
|
|
|
Namespace: namespace,
|
|
|
|
Subsystem: replicatorSubsystem,
|
|
|
|
Name: name,
|
|
|
|
Help: help,
|
|
|
|
})
|
|
|
|
}
|