From efcd12c71e396c8852bff87bab487ee68bd408ae Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 1 Jun 2021 14:24:57 +0300 Subject: [PATCH] [#493] cmd/node: Use new config for metrics configuration Signed-off-by: Alex Vanin --- cmd/neofs-node/config.go | 9 ++------- cmd/neofs-node/metrics.go | 5 +++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 291f73d2..74cdef6a 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -19,6 +19,7 @@ import ( crypto "github.com/nspcc-dev/neofs-crypto" "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" loggerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/logger" + metricsconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/metrics" "github.com/nspcc-dev/neofs-node/misc" "github.com/nspcc-dev/neofs-node/pkg/core/container" netmapCore "github.com/nspcc-dev/neofs-node/pkg/core/netmap" @@ -51,10 +52,6 @@ import ( ) const ( - // metrics keys - cfgMetricsAddr = "metrics.address" - cfgMetricsShutdownTimeout = "metrics.shutdown_timeout" - // config keys for cfgNodeInfo cfgNodeKey = "node.key" cfgBootstrapAddress = "node.address" @@ -423,7 +420,7 @@ func initCfg(path string) *cfg { }, } - if c.viper.GetString(cfgMetricsAddr) != "" { + if metricsconfig.Address(c.appCfg) != "" { c.metricsCollector = metrics.NewStorageMetrics() } @@ -472,8 +469,6 @@ func defaultConfiguration(v *viper.Viper) { v.SetDefault(cfgNetmapContract, "") - v.SetDefault(cfgMetricsShutdownTimeout, "30s") - v.SetDefault(cfgPolicerHeadTimeout, 5*time.Second) v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second) diff --git a/cmd/neofs-node/metrics.go b/cmd/neofs-node/metrics.go index 3b83fcf6..4617d191 100644 --- a/cmd/neofs-node/metrics.go +++ b/cmd/neofs-node/metrics.go @@ -3,13 +3,14 @@ package main import ( "context" + metricsconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/metrics" httputil "github.com/nspcc-dev/neofs-node/pkg/util/http" "github.com/prometheus/client_golang/prometheus/promhttp" "go.uber.org/zap" ) func initMetrics(c *cfg) { - addr := c.viper.GetString(cfgMetricsAddr) + addr := metricsconfig.Address(c.appCfg) if addr == "" { return } @@ -21,7 +22,7 @@ func initMetrics(c *cfg) { srv := httputil.New(prm, httputil.WithShutdownTimeout( - c.viper.GetDuration(cfgMetricsShutdownTimeout), + metricsconfig.ShutdownTimeout(c.appCfg), ), )