forked from TrueCloudLab/frostfs-node
[#1054] innerring: add epoch metric
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
876b0c53de
commit
e1137aa09f
3 changed files with 45 additions and 0 deletions
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement"
|
||||
auditSettlement "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/audit"
|
||||
timerEvent "github.com/nspcc-dev/neofs-node/pkg/innerring/timers"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/metrics"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
auditWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit/wrapper"
|
||||
balanceWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance/wrapper"
|
||||
|
@ -80,6 +81,9 @@ type (
|
|||
netmapClient *nmWrapper.Wrapper
|
||||
persistate *state.PersistentStorage
|
||||
|
||||
// metrics
|
||||
metrics *metrics.InnerRingServiceMetrics
|
||||
|
||||
// notary configuration
|
||||
feeConfig *config.FeeConfig
|
||||
mainNotaryConfig *notaryConfig
|
||||
|
@ -909,6 +913,11 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
queueSize: cfg.GetUint32("workers.subnet"),
|
||||
})
|
||||
|
||||
if cfg.GetString("metrics.address") != "" {
|
||||
m := metrics.NewInnerRingMetrics()
|
||||
server.metrics = &m
|
||||
}
|
||||
|
||||
return server, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ func (s *Server) EpochCounter() uint64 {
|
|||
// epoch counter.
|
||||
func (s *Server) SetEpochCounter(val uint64) {
|
||||
s.epochCounter.Store(val)
|
||||
if s.metrics != nil {
|
||||
s.metrics.SetEpoch(val)
|
||||
}
|
||||
}
|
||||
|
||||
// EpochDuration is a getter for a global epoch duration.
|
||||
|
|
33
pkg/metrics/innerring.go
Normal file
33
pkg/metrics/innerring.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package metrics
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
const innerRingSubsystem = "object"
|
||||
|
||||
// InnerRingServiceMetrics contains metrics collected by inner ring.
|
||||
type InnerRingServiceMetrics struct {
|
||||
epoch prometheus.Gauge
|
||||
}
|
||||
|
||||
// NewInnerRingMetrics returns new instance of metrics collectors for inner ring.
|
||||
func NewInnerRingMetrics() InnerRingServiceMetrics {
|
||||
var (
|
||||
epoch = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: innerRingSubsystem,
|
||||
Name: "epoch",
|
||||
Help: "Current epoch as seen by inner-ring node.",
|
||||
})
|
||||
)
|
||||
|
||||
prometheus.MustRegister(epoch)
|
||||
|
||||
return InnerRingServiceMetrics{
|
||||
epoch: epoch,
|
||||
}
|
||||
}
|
||||
|
||||
// SetEpoch updates epoch metrics.
|
||||
func (m InnerRingServiceMetrics) SetEpoch(epoch uint64) {
|
||||
m.epoch.Set(float64(epoch))
|
||||
}
|
Loading…
Reference in a new issue