forked from TrueCloudLab/frostfs-node
[#374] Add inner-ring event metrics
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
8dcd06c587
commit
ebcc8afbee
27 changed files with 287 additions and 113 deletions
|
@ -1,13 +1,23 @@
|
|||
package metrics
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
const innerRingSubsystem = "ir"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
innerRingSubsystem = "ir"
|
||||
innerRingLabelSuccess = "success"
|
||||
innerRingLabelType = "type"
|
||||
)
|
||||
|
||||
// InnerRingServiceMetrics contains metrics collected by inner ring.
|
||||
type InnerRingServiceMetrics struct {
|
||||
epoch metric[prometheus.Gauge]
|
||||
health metric[prometheus.Gauge]
|
||||
epoch metric[prometheus.Gauge]
|
||||
health metric[prometheus.Gauge]
|
||||
eventDuration metric[*prometheus.HistogramVec]
|
||||
}
|
||||
|
||||
// NewInnerRingMetrics returns new instance of metrics collectors for inner ring.
|
||||
|
@ -25,14 +35,22 @@ func NewInnerRingMetrics() *InnerRingServiceMetrics {
|
|||
Name: "health",
|
||||
Help: "Current inner-ring node state.",
|
||||
})
|
||||
eventDuration = newHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: innerRingSubsystem,
|
||||
Name: "event_duration_seconds",
|
||||
Help: "Duration of processing of inner-ring events",
|
||||
}, []string{innerRingLabelType, innerRingLabelSuccess})
|
||||
)
|
||||
|
||||
mustRegister(epoch)
|
||||
mustRegister(health)
|
||||
mustRegister(eventDuration)
|
||||
|
||||
return &InnerRingServiceMetrics{
|
||||
epoch: epoch,
|
||||
health: health,
|
||||
epoch: epoch,
|
||||
health: health,
|
||||
eventDuration: eventDuration,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,3 +63,10 @@ func (m InnerRingServiceMetrics) SetEpoch(epoch uint64) {
|
|||
func (m InnerRingServiceMetrics) SetHealth(s int32) {
|
||||
m.health.value.Set(float64(s))
|
||||
}
|
||||
|
||||
func (m InnerRingServiceMetrics) AddEvent(d time.Duration, typ string, success bool) {
|
||||
m.eventDuration.value.With(prometheus.Labels{
|
||||
innerRingLabelType: typ,
|
||||
innerRingLabelSuccess: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue