forked from TrueCloudLab/frostfs-node
[#426] cmd/neofs-node: Add metrics collector in node
Disabled by default. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
534ce03421
commit
3c0e47e6fd
4 changed files with 34 additions and 2 deletions
|
@ -58,6 +58,10 @@ const (
|
|||
cfgProfilerAddr = "pprof.address"
|
||||
cfgProfilerTTL = "pprof.shutdown_ttl"
|
||||
|
||||
// metrics keys
|
||||
cfgMetricsEnable = "metrics.enabled"
|
||||
cfgMetricsAddr = "metrics.address"
|
||||
|
||||
// config keys for cfgNodeInfo
|
||||
cfgNodeKey = "node.key"
|
||||
cfgBootstrapAddress = "node.address"
|
||||
|
@ -180,6 +184,8 @@ type cfg struct {
|
|||
|
||||
profiler profiler.Profiler
|
||||
|
||||
metrics profiler.Metrics
|
||||
|
||||
workers []worker
|
||||
|
||||
respSvc *response.Service
|
||||
|
@ -414,6 +420,9 @@ func defaultConfiguration(v *viper.Viper) {
|
|||
v.SetDefault(cfgProfilerAddr, ":6060")
|
||||
v.SetDefault(cfgProfilerTTL, "30s")
|
||||
|
||||
v.SetDefault(cfgMetricsEnable, false)
|
||||
v.SetDefault(cfgMetricsAddr, ":9090")
|
||||
|
||||
v.SetDefault(cfgGCQueueSize, 1000)
|
||||
v.SetDefault(cfgGCQueueTick, "5s")
|
||||
v.SetDefault(cfgGCTimeout, "5s")
|
||||
|
@ -448,6 +457,7 @@ func initLocalStorage(c *cfg) {
|
|||
|
||||
ls := engine.New(
|
||||
engine.WithLogger(c.log),
|
||||
engine.WithMetrics(c.viper.GetBool(cfgMetricsEnable)),
|
||||
)
|
||||
|
||||
for _, opts := range c.cfgObject.cfgLocalStorage.shardOpts {
|
||||
|
|
|
@ -48,6 +48,7 @@ func initApp(c *cfg) {
|
|||
initSessionService(c)
|
||||
initObjectService(c)
|
||||
initProfiler(c)
|
||||
initMetrics(c)
|
||||
initControlService(c)
|
||||
|
||||
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Open())
|
||||
|
@ -61,6 +62,7 @@ func bootUp(c *cfg) {
|
|||
serveGRPC(c)
|
||||
bootstrapNode(c)
|
||||
startWorkers(c)
|
||||
serveMetrics(c)
|
||||
}
|
||||
|
||||
func wait(c *cfg) {
|
||||
|
|
15
cmd/neofs-node/metrics.go
Normal file
15
cmd/neofs-node/metrics.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/profiler"
|
||||
)
|
||||
|
||||
func initMetrics(c *cfg) {
|
||||
c.metrics = profiler.NewMetrics(c.log, c.viper)
|
||||
}
|
||||
|
||||
func serveMetrics(c *cfg) {
|
||||
if c.metrics != nil {
|
||||
c.metrics.Start(c.ctx)
|
||||
}
|
||||
}
|
|
@ -299,7 +299,7 @@ func initObjectService(c *cfg) {
|
|||
)
|
||||
|
||||
// build service pipeline
|
||||
// grpc | acl | signature | response | split
|
||||
// grpc | <metrics> | acl | signature | response | split
|
||||
|
||||
splitSvc := objectService.NewTransportSplitter(
|
||||
c.cfgGRPC.maxChunkSize,
|
||||
|
@ -344,8 +344,13 @@ func initObjectService(c *cfg) {
|
|||
acl.WithNetmapState(c.cfgNetmap.state),
|
||||
)
|
||||
|
||||
var firstSvc objectService.ServiceServer = aclSvc
|
||||
if c.viper.GetBool(cfgMetricsEnable) {
|
||||
firstSvc = objectService.NewMetricCollector(aclSvc)
|
||||
}
|
||||
|
||||
objectGRPC.RegisterObjectServiceServer(c.cfgGRPC.server,
|
||||
objectTransportGRPC.New(aclSvc),
|
||||
objectTransportGRPC.New(firstSvc),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue