satellite/rangedloop: wire up metrics observer

Final touches on https://github.com/storj/storj/issues/5236.

Change-Id: I2259ec4e7825d20db9efb36beb42d6309dee55ba
This commit is contained in:
Andrew Harding 2022-12-09 14:34:32 -07:00 committed by Storj Robot
parent b9f0a38846
commit 1cb2eb4c3b
4 changed files with 38 additions and 13 deletions

View File

@ -663,8 +663,12 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB,
}
{ // setup metrics service
log := peer.Log.Named("metrics")
if config.Metrics.UseRangedLoop {
log.Info("using ranged loop")
} else {
peer.Metrics.Chore = metrics.NewChore(
peer.Log.Named("metrics"),
log,
config.Metrics,
peer.Metainfo.SegmentLoop,
)
@ -676,6 +680,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB,
peer.Debug.Server.Panel.Add(
debug.Cycle("Metrics", peer.Metrics.Chore.Loop))
}
}
return peer, nil
}

View File

@ -23,6 +23,7 @@ var (
// Config contains configurable values for metrics collection.
type Config struct {
UseRangedLoop bool `help:"whether to use ranged loop instead of segment loop" default:"false"`
}
// Chore implements the metrics chore.

View File

@ -21,6 +21,7 @@ import (
"storj.io/storj/satellite/metabase"
"storj.io/storj/satellite/metabase/rangedloop"
"storj.io/storj/satellite/metabase/rangedloop/rangedlooptest"
"storj.io/storj/satellite/metrics"
)
// RangedLoop is the satellite ranged loop process.
@ -39,6 +40,10 @@ type RangedLoop struct {
Server *debug.Server
}
Metrics struct {
Observer rangedloop.Observer
}
RangedLoop struct {
Service *rangedloop.Service
}
@ -74,10 +79,21 @@ func NewRangedLoop(log *zap.Logger, full *identity.FullIdentity, db DB, metabase
})
}
{ // setup metrics observer
peer.Metrics.Observer = metrics.NewObserver()
}
{ // setup ranged loop
var observers []rangedloop.Observer
// TODO: replace with real segment provider
segments := &rangedlooptest.RangeSplitter{}
peer.RangedLoop.Service = rangedloop.NewService(log.Named("rangedloop"), config.RangedLoop, segments, nil)
if config.Metrics.UseRangedLoop {
observers = append(observers, peer.Metrics.Observer)
}
peer.RangedLoop.Service = rangedloop.NewService(log.Named("rangedloop"), config.RangedLoop, segments, observers)
peer.Services.Add(lifecycle.Item{
Name: "rangeloop",

View File

@ -679,6 +679,9 @@ identity.key-path: /root/.local/share/storj/identity/satellite/identity.key
# how frequently to send up telemetry. Ignored for certain applications.
# metrics.interval: 1m0s
# whether to use ranged loop instead of segment loop
# metrics.use-ranged-loop: false
# path to log for oom notices
# monkit.hw.oomlog: /var/log/kern.log