forked from TrueCloudLab/frostfs-node
[#1054] neofs-node: add epoch metric
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
e1137aa09f
commit
e96eb3e00b
3 changed files with 24 additions and 0 deletions
|
@ -316,6 +316,7 @@ func initCfg(path string) *cfg {
|
||||||
|
|
||||||
if metricsconfig.Address(c.appCfg) != "" {
|
if metricsconfig.Address(c.appCfg) != "" {
|
||||||
c.metricsCollector = metrics.NewStorageMetrics()
|
c.metricsCollector = metrics.NewStorageMetrics()
|
||||||
|
netState.metrics = c.metricsCollector
|
||||||
}
|
}
|
||||||
|
|
||||||
c.onShutdown(c.clientCache.CloseAll) // clean up connections
|
c.onShutdown(c.clientCache.CloseAll) // clean up connections
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||||
nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node"
|
nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/metrics"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
|
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
|
||||||
|
@ -30,6 +31,8 @@ type networkState struct {
|
||||||
controlNetStatus atomic.Value // control.NetmapStatus
|
controlNetStatus atomic.Value // control.NetmapStatus
|
||||||
|
|
||||||
nodeInfo atomic.Value // *netmapSDK.NodeInfo
|
nodeInfo atomic.Value // *netmapSDK.NodeInfo
|
||||||
|
|
||||||
|
metrics *metrics.StorageMetrics
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNetworkState() *networkState {
|
func newNetworkState() *networkState {
|
||||||
|
@ -44,6 +47,9 @@ func (s *networkState) CurrentEpoch() uint64 {
|
||||||
|
|
||||||
func (s *networkState) setCurrentEpoch(v uint64) {
|
func (s *networkState) setCurrentEpoch(v uint64) {
|
||||||
s.epoch.Store(v)
|
s.epoch.Store(v)
|
||||||
|
if s.metrics != nil {
|
||||||
|
s.metrics.SetEpoch(v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *networkState) setNodeInfo(ni *netmapSDK.NodeInfo) {
|
func (s *networkState) setNodeInfo(ni *netmapSDK.NodeInfo) {
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
|
import "github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
const namespace = "neofs_node"
|
const namespace = "neofs_node"
|
||||||
|
|
||||||
type StorageMetrics struct {
|
type StorageMetrics struct {
|
||||||
objectServiceMetrics
|
objectServiceMetrics
|
||||||
engineMetrics
|
engineMetrics
|
||||||
|
epoch prometheus.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorageMetrics() *StorageMetrics {
|
func NewStorageMetrics() *StorageMetrics {
|
||||||
|
@ -14,8 +17,22 @@ func NewStorageMetrics() *StorageMetrics {
|
||||||
engine := newEngineMetrics()
|
engine := newEngineMetrics()
|
||||||
engine.register()
|
engine.register()
|
||||||
|
|
||||||
|
epoch := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: innerRingSubsystem,
|
||||||
|
Name: "epoch",
|
||||||
|
Help: "Current epoch as seen by inner-ring node.",
|
||||||
|
})
|
||||||
|
prometheus.MustRegister(epoch)
|
||||||
|
|
||||||
return &StorageMetrics{
|
return &StorageMetrics{
|
||||||
objectServiceMetrics: objectService,
|
objectServiceMetrics: objectService,
|
||||||
engineMetrics: engine,
|
engineMetrics: engine,
|
||||||
|
epoch: epoch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetEpoch updates epoch metric.
|
||||||
|
func (m *StorageMetrics) SetEpoch(epoch uint64) {
|
||||||
|
m.epoch.Set(float64(epoch))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue