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"
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
const namespace = "frostfs_node"
|
2021-03-16 08:14:56 +00:00
|
|
|
|
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
|
2023-04-10 09:43:51 +00:00
|
|
|
shardMetrics
|
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()
|
|
|
|
|
2023-04-10 09:43:51 +00:00
|
|
|
shard := newShardMetrics()
|
|
|
|
shard.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,
|
2023-04-10 09:43:51 +00:00
|
|
|
shardMetrics: shard,
|
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))
|
|
|
|
}
|