2021-03-16 08:14:56 +00:00
|
|
|
package metrics
|
|
|
|
|
2023-05-24 07:01:50 +00:00
|
|
|
import (
|
2023-05-31 09:25:32 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
2023-05-24 07:01:50 +00:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
2021-12-28 10:39:42 +00:00
|
|
|
|
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-05-19 08:17:19 +00:00
|
|
|
|
|
|
|
writeCacheMetrics *writeCacheMetrics
|
2023-05-24 07:01:50 +00:00
|
|
|
treeService *treeServiceMetrics
|
2023-05-31 09:25:32 +00:00
|
|
|
epoch prometheus.Gauge
|
2023-05-29 14:32:13 +00:00
|
|
|
gc *gcMetrics
|
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()
|
|
|
|
|
|
|
|
engine := newEngineMetrics()
|
|
|
|
|
2022-07-19 15:16:42 +00:00
|
|
|
state := newStateMetrics()
|
|
|
|
|
2023-05-12 08:44:21 +00:00
|
|
|
replicator := newReplicatorMetrics()
|
|
|
|
|
2023-05-24 07:01:50 +00:00
|
|
|
treeService := newTreeServiceMetrics()
|
|
|
|
|
2023-05-31 09:25:32 +00:00
|
|
|
epoch := metrics.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-05-19 08:17:19 +00:00
|
|
|
writeCacheMetrics := newWriteCacheMetrics()
|
|
|
|
|
2023-05-29 14:32:13 +00:00
|
|
|
gc := newGCMetrics()
|
|
|
|
|
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,
|
2023-05-24 07:01:50 +00:00
|
|
|
treeService: treeService,
|
2021-12-28 10:39:42 +00:00
|
|
|
epoch: epoch,
|
2023-05-19 08:17:19 +00:00
|
|
|
writeCacheMetrics: writeCacheMetrics,
|
2023-05-29 14:32:13 +00:00
|
|
|
gc: gc,
|
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-05-31 09:25:32 +00:00
|
|
|
m.epoch.Set(float64(epoch))
|
2021-12-28 10:39:42 +00:00
|
|
|
}
|
2023-05-19 08:17:19 +00:00
|
|
|
|
|
|
|
// WriteCache returns WriteCache metrics.
|
|
|
|
func (m *NodeMetrics) WriteCache() WriteCacheMetrics {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return m.writeCacheMetrics
|
|
|
|
}
|
2023-05-24 07:01:50 +00:00
|
|
|
|
2023-05-26 09:15:50 +00:00
|
|
|
func (m *NodeMetrics) TreeService() TreeMetricsRegister {
|
2023-05-24 07:01:50 +00:00
|
|
|
return m.treeService
|
|
|
|
}
|
2023-05-29 14:32:13 +00:00
|
|
|
|
|
|
|
func (m *NodeMetrics) GC() GCMetrics {
|
|
|
|
return m.gc
|
|
|
|
}
|