package metrics import ( "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics" "github.com/prometheus/client_golang/prometheus" ) const namespace = "frostfs_node" type NodeMetrics struct { objectServiceMetrics engineMetrics stateMetrics replicatorMetrics writeCacheMetrics *writeCacheMetrics treeService *treeServiceMetrics epoch prometheus.Gauge gc *gcMetrics } func NewNodeMetrics() *NodeMetrics { objectService := newObjectServiceMetrics() engine := newEngineMetrics() state := newStateMetrics() replicator := newReplicatorMetrics() treeService := newTreeServiceMetrics() epoch := metrics.NewGauge(prometheus.GaugeOpts{ Namespace: namespace, Subsystem: innerRingSubsystem, Name: "epoch", Help: "Current epoch as seen by inner-ring node.", }) writeCacheMetrics := newWriteCacheMetrics() gc := newGCMetrics() return &NodeMetrics{ objectServiceMetrics: objectService, engineMetrics: engine, stateMetrics: state, replicatorMetrics: replicator, treeService: treeService, epoch: epoch, writeCacheMetrics: writeCacheMetrics, gc: gc, } } // SetEpoch updates epoch metric. func (m *NodeMetrics) SetEpoch(epoch uint64) { m.epoch.Set(float64(epoch)) } // WriteCache returns WriteCache metrics. func (m *NodeMetrics) WriteCache() WriteCacheMetrics { if m == nil { return nil } return m.writeCacheMetrics } func (m *NodeMetrics) TreeService() TreeMetricsRegister { return m.treeService } func (m *NodeMetrics) GC() GCMetrics { return m.gc }