[#1614] metrics: Add health metrics

Also, rename metrics structure since it collects not only storage metrics
now.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-07-19 18:16:42 +03:00 committed by fyrchik
parent 2455b72844
commit 581a9901c9
4 changed files with 40 additions and 7 deletions

View file

@ -4,19 +4,23 @@ import "github.com/prometheus/client_golang/prometheus"
const namespace = "neofs_node"
type StorageMetrics struct {
type NodeMetrics struct {
objectServiceMetrics
engineMetrics
stateMetrics
epoch prometheus.Gauge
}
func NewStorageMetrics() *StorageMetrics {
func NewNodeMetrics() *NodeMetrics {
objectService := newObjectServiceMetrics()
objectService.register()
engine := newEngineMetrics()
engine.register()
state := newStateMetrics()
state.register()
epoch := prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: innerRingSubsystem,
@ -25,14 +29,15 @@ func NewStorageMetrics() *StorageMetrics {
})
prometheus.MustRegister(epoch)
return &StorageMetrics{
return &NodeMetrics{
objectServiceMetrics: objectService,
engineMetrics: engine,
stateMetrics: state,
epoch: epoch,
}
}
// SetEpoch updates epoch metric.
func (m *StorageMetrics) SetEpoch(epoch uint64) {
func (m *NodeMetrics) SetEpoch(epoch uint64) {
m.epoch.Set(float64(epoch))
}