forked from TrueCloudLab/frostfs-node
[#412] node: Replace metrics package
Use observability module. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
74578052f9
commit
c09144ecf1
15 changed files with 162 additions and 459 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
|
@ -15,27 +16,27 @@ const (
|
|||
|
||||
// InnerRingServiceMetrics contains metrics collected by inner ring.
|
||||
type InnerRingServiceMetrics struct {
|
||||
epoch metric[prometheus.Gauge]
|
||||
health metric[prometheus.Gauge]
|
||||
eventDuration metric[*prometheus.HistogramVec]
|
||||
epoch prometheus.Gauge
|
||||
health prometheus.Gauge
|
||||
eventDuration *prometheus.HistogramVec
|
||||
}
|
||||
|
||||
// NewInnerRingMetrics returns new instance of metrics collectors for inner ring.
|
||||
func NewInnerRingMetrics() *InnerRingServiceMetrics {
|
||||
var (
|
||||
epoch = newGauge(prometheus.GaugeOpts{
|
||||
epoch = metrics.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: innerRingSubsystem,
|
||||
Name: "epoch",
|
||||
Help: "Current epoch as seen by inner-ring node.",
|
||||
})
|
||||
health = newGauge(prometheus.GaugeOpts{
|
||||
health = metrics.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: innerRingSubsystem,
|
||||
Name: "health",
|
||||
Help: "Current inner-ring node state.",
|
||||
})
|
||||
eventDuration = newHistogramVec(prometheus.HistogramOpts{
|
||||
eventDuration = metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: innerRingSubsystem,
|
||||
Name: "event_duration_seconds",
|
||||
|
@ -43,10 +44,6 @@ func NewInnerRingMetrics() *InnerRingServiceMetrics {
|
|||
}, []string{innerRingLabelType, innerRingLabelSuccess})
|
||||
)
|
||||
|
||||
mustRegister(epoch)
|
||||
mustRegister(health)
|
||||
mustRegister(eventDuration)
|
||||
|
||||
return &InnerRingServiceMetrics{
|
||||
epoch: epoch,
|
||||
health: health,
|
||||
|
@ -56,16 +53,16 @@ func NewInnerRingMetrics() *InnerRingServiceMetrics {
|
|||
|
||||
// SetEpoch updates epoch metrics.
|
||||
func (m InnerRingServiceMetrics) SetEpoch(epoch uint64) {
|
||||
m.epoch.value.Set(float64(epoch))
|
||||
m.epoch.Set(float64(epoch))
|
||||
}
|
||||
|
||||
// SetHealth updates health metrics.
|
||||
func (m InnerRingServiceMetrics) SetHealth(s int32) {
|
||||
m.health.value.Set(float64(s))
|
||||
m.health.Set(float64(s))
|
||||
}
|
||||
|
||||
func (m InnerRingServiceMetrics) AddEvent(d time.Duration, typ string, success bool) {
|
||||
m.eventDuration.value.With(prometheus.Labels{
|
||||
m.eventDuration.With(prometheus.Labels{
|
||||
innerRingLabelType: typ,
|
||||
innerRingLabelSuccess: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue