frostfs-node/pkg/metrics/node.go
Evgenii Stratonikov 6fef2726b8 [#164] metrics: Allow to export metrics description
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-04-24 09:01:13 +00:00

43 lines
908 B
Go

package metrics
import "github.com/prometheus/client_golang/prometheus"
const namespace = "frostfs_node"
type NodeMetrics struct {
objectServiceMetrics
engineMetrics
stateMetrics
epoch metric[prometheus.Gauge]
}
func NewNodeMetrics() *NodeMetrics {
objectService := newObjectServiceMetrics()
objectService.register()
engine := newEngineMetrics()
engine.register()
state := newStateMetrics()
state.register()
epoch := newGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: innerRingSubsystem,
Name: "epoch",
Help: "Current epoch as seen by inner-ring node.",
})
mustRegister(epoch)
return &NodeMetrics{
objectServiceMetrics: objectService,
engineMetrics: engine,
stateMetrics: state,
epoch: epoch,
}
}
// SetEpoch updates epoch metric.
func (m *NodeMetrics) SetEpoch(epoch uint64) {
m.epoch.value.Set(float64(epoch))
}