forked from TrueCloudLab/frostfs-node
[#451] metrics: Move to internal
`metrics` don't look like something others want to import. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
11a38a0a84
commit
81ea91de52
35 changed files with 14 additions and 14 deletions
61
internal/metrics/replicator.go
Normal file
61
internal/metrics/replicator.go
Normal file
|
@ -0,0 +1,61 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
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_total", "Number of in-flight requests"),
|
||||
processedObjects: newReplicatorCounter("processed_objects_total", "Number of objects processed since the node startup"),
|
||||
totalReplicatedPayloadSize: newReplicatorCounter("total_replicated_payload_size_bytes", "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,
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue