[#493] cmd/node: Use new config for metrics configuration

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-06-01 14:24:57 +03:00 committed by Alex Vanin
parent 3fbf5e05b2
commit efcd12c71e
2 changed files with 5 additions and 9 deletions

View file

@ -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)

View file

@ -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),
),
)