diff --git a/cmd/neofs-ir/defaults.go b/cmd/neofs-ir/defaults.go index a9ed663f6..6b571a570 100644 --- a/cmd/neofs-ir/defaults.go +++ b/cmd/neofs-ir/defaults.go @@ -37,11 +37,11 @@ func newConfig(path string) (*viper.Viper, error) { func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("logger.level", "info") - cfg.SetDefault("profiler.address", "localhost:6060") - cfg.SetDefault("profiler.shutdown_timeout", "30s") + cfg.SetDefault("pprof.address", "localhost:6060") + cfg.SetDefault("pprof.shutdown_timeout", "30s") - cfg.SetDefault("metrics.address", "localhost:9090") - cfg.SetDefault("metrics.shutdown_timeout", "30s") + cfg.SetDefault("prometheus.address", "localhost:9090") + cfg.SetDefault("prometheus.shutdown_timeout", "30s") cfg.SetDefault("without_mainnet", false) diff --git a/cmd/neofs-ir/main.go b/cmd/neofs-ir/main.go index f6eb1c6d7..7274d2c9c 100644 --- a/cmd/neofs-ir/main.go +++ b/cmd/neofs-ir/main.go @@ -110,51 +110,31 @@ func main() { func initHTTPServers(cfg *viper.Viper, log *logger.Logger) []*httputil.Server { items := []struct { cfgPrefix string - oldPrefix string handler func() http.Handler }{ - {"pprof", "profiler", httputil.Handler}, - {"prometheus", "metrics", promhttp.Handler}, + {"pprof", httputil.Handler}, + {"prometheus", promhttp.Handler}, } httpServers := make([]*httputil.Server, 0, len(items)) for _, item := range items { - var printDeprecatedMsg bool if !cfg.GetBool(item.cfgPrefix + ".enabled") { - if !cfg.GetBool(item.oldPrefix + ".enabled") { - log.Info(item.cfgPrefix + " is disabled, skip") - continue - } - printDeprecatedMsg = true + log.Info(item.cfgPrefix + " is disabled, skip") + continue } - // The default value is set only for the deprecated prefix, so empty string can be returned. addr := cfg.GetString(item.cfgPrefix + ".address") - if addr == "" { - addr = cfg.GetString(item.oldPrefix + ".address") - printDeprecatedMsg = true - } var prm httputil.Prm prm.Address = addr prm.Handler = item.handler() - timeout := cfg.GetDuration(item.cfgPrefix + ".shutdown_timeout") - if timeout == 0 { - timeout = cfg.GetDuration(item.oldPrefix + ".shutdown_timeout") - printDeprecatedMsg = true - } - - if printDeprecatedMsg { - log.Info(item.oldPrefix + " config section is deprecated, use " + item.cfgPrefix) - } - httpServers = append(httpServers, httputil.New(prm, httputil.WithShutdownTimeout( - timeout, + cfg.GetDuration(item.cfgPrefix+".shutdown_timeout"), ), ), ) diff --git a/cmd/neofs-node/config/metrics/config.go b/cmd/neofs-node/config/metrics/config.go index 03514016a..d5941a6fd 100644 --- a/cmd/neofs-node/config/metrics/config.go +++ b/cmd/neofs-node/config/metrics/config.go @@ -7,8 +7,7 @@ import ( ) const ( - subsection = "prometheus" - subsectionOld = "metrics" + subsection = "prometheus" // ShutdownTimeoutDefault is a default value for metrics HTTP service timeout. ShutdownTimeoutDefault = 30 * time.Second @@ -18,25 +17,19 @@ const ( ) // Enabled returns the value of "enabled" config parameter -// from "metrics" section. +// from "prometheus" section. // // Returns false if the value is missing or invalid. func Enabled(c *config.Config) bool { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - return config.BoolSafe(s, "enabled") + return config.BoolSafe(c.Sub(subsection), "enabled") } // ShutdownTimeout returns the value of "shutdown_timeout" config parameter -// from "metrics" section. +// from "prometheus" section. // // Returns ShutdownTimeoutDefault if the value is not positive duration. func ShutdownTimeout(c *config.Config) time.Duration { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - v := config.DurationSafe(s, "shutdown_timeout") + v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout") if v > 0 { return v } @@ -45,14 +38,11 @@ func ShutdownTimeout(c *config.Config) time.Duration { } // Address returns the value of "address" config parameter -// from "metrics" section. +// from "prometheus" section. // // Returns AddressDefault if the value is not set. func Address(c *config.Config) string { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - v := config.StringSafe(s, "address") + v := config.StringSafe(c.Sub(subsection), "address") if v != "" { return v } diff --git a/cmd/neofs-node/config/profiler/config.go b/cmd/neofs-node/config/profiler/config.go index 2ad9cee7a..6419b803a 100644 --- a/cmd/neofs-node/config/profiler/config.go +++ b/cmd/neofs-node/config/profiler/config.go @@ -7,8 +7,7 @@ import ( ) const ( - subsection = "pprof" - subsectionOld = "profiler" + subsection = "pprof" // ShutdownTimeoutDefault is a default value for profiler HTTP service timeout. ShutdownTimeoutDefault = 30 * time.Second @@ -18,25 +17,19 @@ const ( ) // Enabled returns the value of "enabled" config parameter -// from "profiler" section. +// from "pprof" section. // // Returns false if the value is missing or invalid. func Enabled(c *config.Config) bool { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - return config.BoolSafe(s, "enabled") + return config.BoolSafe(c.Sub(subsection), "enabled") } // ShutdownTimeout returns the value of "shutdown_timeout" config parameter -// from "profiler" section. +// from "pprof" section. // // Returns ShutdownTimeoutDefault if the value is not positive duration. func ShutdownTimeout(c *config.Config) time.Duration { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - v := config.DurationSafe(s, "shutdown_timeout") + v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout") if v > 0 { return v } @@ -45,12 +38,11 @@ func ShutdownTimeout(c *config.Config) time.Duration { } // Address returns the value of "address" config parameter -// from "profiler" section. +// from "pprof" section. // // Returns AddressDefault if the value is not set. func Address(c *config.Config) string { s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) v := config.StringSafe(s, "address") if v != "" { diff --git a/config/example/node.env b/config/example/node.env index 8a018d1c8..2f91b3696 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -1,12 +1,12 @@ NEOFS_LOGGER_LEVEL=debug -NEOFS_PROFILER_ENABLED=true -NEOFS_PROFILER_ADDRESS=localhost:6060 -NEOFS_PROFILER_SHUTDOWN_TIMEOUT=15s +NEOFS_PPROF_ENABLED=true +NEOFS_PPROF_ADDRESS=localhost:6060 +NEOFS_PPROF_SHUTDOWN_TIMEOUT=15s -NEOFS_METRICS_ENABLED=true -NEOFS_METRICS_ADDRESS=localhost:9090 -NEOFS_METRICS_SHUTDOWN_TIMEOUT=15s +NEOFS_PROMETHEUS_ENABLED=true +NEOFS_PROMETHEUS_ADDRESS=localhost:9090 +NEOFS_PROMETHEUS_SHUTDOWN_TIMEOUT=15s # Node section NEOFS_NODE_KEY=./wallet.key diff --git a/config/example/node.json b/config/example/node.json index 53c4aaa61..0e19233ca 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -2,12 +2,12 @@ "logger": { "level": "debug" }, - "profiler": { + "pprof": { "enabled": true, "address": "localhost:6060", "shutdown_timeout": "15s" }, - "metrics": { + "prometheus": { "enabled": true, "address": "localhost:9090", "shutdown_timeout": "15s"