2021-03-16 08:14:56 +00:00
|
|
|
package metrics
|
|
|
|
|
2021-12-28 10:39:42 +00:00
|
|
|
import "github.com/prometheus/client_golang/prometheus"
|
|
|
|
|
2021-03-16 08:14:56 +00:00
|
|
|
const namespace = "neofs_node"
|
|
|
|
|
2022-07-19 15:16:42 +00:00
|
|
|
type NodeMetrics struct {
|
2021-03-16 08:14:56 +00:00
|
|
|
objectServiceMetrics
|
|
|
|
engineMetrics
|
2022-07-19 15:16:42 +00:00
|
|
|
stateMetrics
|
2021-12-28 10:39:42 +00:00
|
|
|
epoch prometheus.Gauge
|
2021-03-16 08:14:56 +00:00
|
|
|
}
|
|
|
|
|
2022-07-19 15:16:42 +00:00
|
|
|
func NewNodeMetrics() *NodeMetrics {
|
2021-03-16 08:14:56 +00:00
|
|
|
objectService := newObjectServiceMetrics()
|
|
|
|
objectService.register()
|
|
|
|
|
|
|
|
engine := newEngineMetrics()
|
|
|
|
engine.register()
|
|
|
|
|
2022-07-19 15:16:42 +00:00
|
|
|
state := newStateMetrics()
|
|
|
|
state.register()
|
|
|
|
|
2021-12-28 10:39:42 +00:00
|
|
|
epoch := prometheus.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Namespace: namespace,
|
|
|
|
Subsystem: innerRingSubsystem,
|
|
|
|
Name: "epoch",
|
|
|
|
Help: "Current epoch as seen by inner-ring node.",
|
|
|
|
})
|
|
|
|
prometheus.MustRegister(epoch)
|
|
|
|
|
2022-07-19 15:16:42 +00:00
|
|
|
return &NodeMetrics{
|
2021-03-16 08:14:56 +00:00
|
|
|
objectServiceMetrics: objectService,
|
|
|
|
engineMetrics: engine,
|
2022-07-19 15:16:42 +00:00
|
|
|
stateMetrics: state,
|
2021-12-28 10:39:42 +00:00
|
|
|
epoch: epoch,
|
2021-03-16 08:14:56 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-28 10:39:42 +00:00
|
|
|
|
|
|
|
// SetEpoch updates epoch metric.
|
2022-07-19 15:16:42 +00:00
|
|
|
func (m *NodeMetrics) SetEpoch(epoch uint64) {
|
2021-12-28 10:39:42 +00:00
|
|
|
m.epoch.Set(float64(epoch))
|
|
|
|
}
|