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-05-12 08:44:21 +00:00
|
|
|
replicatorMetrics
|
2023-04-05 10:39:02 +00:00
|
|
|
epoch metric[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-05-12 08:44:21 +00:00
|
|
|
replicator := newReplicatorMetrics()
|
|
|
|
replicator.register()
|
|
|
|
|
2023-04-05 10:39:02 +00:00
|
|
|
epoch := newGauge(prometheus.GaugeOpts{
|
2021-12-28 10:39:42 +00:00
|
|
|
Namespace: namespace,
|
|
|
|
Subsystem: innerRingSubsystem,
|
|
|
|
Name: "epoch",
|
|
|
|
Help: "Current epoch as seen by inner-ring node.",
|
|
|
|
})
|
2023-04-05 08:44:13 +00:00
|
|
|
mustRegister(epoch)
|
2021-12-28 10:39:42 +00:00
|
|
|
|
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-05-12 08:44:21 +00:00
|
|
|
replicatorMetrics: replicator,
|
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) {
|
2023-04-05 10:39:02 +00:00
|
|
|
m.epoch.value.Set(float64(epoch))
|
2021-12-28 10:39:42 +00:00
|
|
|
}
|