forked from TrueCloudLab/frostfs-node
[#68] Add go pprof to neofs-storage
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
69a69cdbee
commit
2ee24998ba
3 changed files with 29 additions and 0 deletions
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||
tokenStorage "github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/profiler"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/zap"
|
||||
|
@ -35,6 +36,11 @@ const (
|
|||
cfgLogInitSampling = "logger.sampling.initial"
|
||||
cfgLogThereafterSampling = "logger.sampling.thereafter"
|
||||
|
||||
// pprof keys
|
||||
cfgProfilerEnable = "pprof.enabled"
|
||||
cfgProfilerAddr = "pprof.address"
|
||||
cfgProfilerTTL = "pprof.shutdown_ttl"
|
||||
|
||||
// config keys for cfgNodeInfo
|
||||
cfgNodeKey = "node.key"
|
||||
cfgBootstrapAddress = "node.address"
|
||||
|
@ -97,6 +103,8 @@ type cfg struct {
|
|||
localAddr *network.Address
|
||||
|
||||
cfgObject cfgObject
|
||||
|
||||
profiler profiler.Profiler
|
||||
}
|
||||
|
||||
type cfgGRPC struct {
|
||||
|
@ -269,6 +277,10 @@ func defaultConfiguration(v *viper.Viper) {
|
|||
v.SetDefault(cfgLogTrace, "fatal")
|
||||
v.SetDefault(cfgLogInitSampling, 1000)
|
||||
v.SetDefault(cfgLogThereafterSampling, 1000)
|
||||
|
||||
v.SetDefault(cfgProfilerEnable, false)
|
||||
v.SetDefault(cfgProfilerAddr, ":6060")
|
||||
v.SetDefault(cfgProfilerTTL, "30s")
|
||||
}
|
||||
|
||||
func (c *cfg) LocalAddress() *network.Address {
|
||||
|
|
|
@ -37,9 +37,11 @@ func init_(c *cfg) {
|
|||
initContainerService(c)
|
||||
initSessionService(c)
|
||||
initObjectService(c)
|
||||
initProfiler(c)
|
||||
}
|
||||
|
||||
func bootUp(c *cfg) {
|
||||
serveProfiler(c)
|
||||
serveGRPC(c)
|
||||
bootstrapNode(c)
|
||||
}
|
||||
|
|
15
cmd/neofs-node/pprof.go
Normal file
15
cmd/neofs-node/pprof.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/profiler"
|
||||
)
|
||||
|
||||
func initProfiler(c *cfg) {
|
||||
c.profiler = profiler.NewProfiler(c.log, c.viper)
|
||||
}
|
||||
|
||||
func serveProfiler(c *cfg) {
|
||||
if c.profiler != nil {
|
||||
c.profiler.Start(c.ctx)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue