[#493] cmd/node: Use new config for metrics configuration
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
3fbf5e05b2
commit
efcd12c71e
2 changed files with 5 additions and 9 deletions
|
@ -19,6 +19,7 @@ import (
|
||||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||||
loggerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/logger"
|
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/misc"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||||
netmapCore "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
netmapCore "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||||
|
@ -51,10 +52,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// metrics keys
|
|
||||||
cfgMetricsAddr = "metrics.address"
|
|
||||||
cfgMetricsShutdownTimeout = "metrics.shutdown_timeout"
|
|
||||||
|
|
||||||
// config keys for cfgNodeInfo
|
// config keys for cfgNodeInfo
|
||||||
cfgNodeKey = "node.key"
|
cfgNodeKey = "node.key"
|
||||||
cfgBootstrapAddress = "node.address"
|
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()
|
c.metricsCollector = metrics.NewStorageMetrics()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,8 +469,6 @@ func defaultConfiguration(v *viper.Viper) {
|
||||||
|
|
||||||
v.SetDefault(cfgNetmapContract, "")
|
v.SetDefault(cfgNetmapContract, "")
|
||||||
|
|
||||||
v.SetDefault(cfgMetricsShutdownTimeout, "30s")
|
|
||||||
|
|
||||||
v.SetDefault(cfgPolicerHeadTimeout, 5*time.Second)
|
v.SetDefault(cfgPolicerHeadTimeout, 5*time.Second)
|
||||||
|
|
||||||
v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second)
|
v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second)
|
||||||
|
|
|
@ -3,13 +3,14 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
metricsconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/metrics"
|
||||||
httputil "github.com/nspcc-dev/neofs-node/pkg/util/http"
|
httputil "github.com/nspcc-dev/neofs-node/pkg/util/http"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initMetrics(c *cfg) {
|
func initMetrics(c *cfg) {
|
||||||
addr := c.viper.GetString(cfgMetricsAddr)
|
addr := metricsconfig.Address(c.appCfg)
|
||||||
if addr == "" {
|
if addr == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -21,7 +22,7 @@ func initMetrics(c *cfg) {
|
||||||
|
|
||||||
srv := httputil.New(prm,
|
srv := httputil.New(prm,
|
||||||
httputil.WithShutdownTimeout(
|
httputil.WithShutdownTimeout(
|
||||||
c.viper.GetDuration(cfgMetricsShutdownTimeout),
|
metricsconfig.ShutdownTimeout(c.appCfg),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue