[#1602] config: Enable metrics
and profiler
services with a flag
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
12dc5c3395
commit
ac46d1a11f
16 changed files with 53 additions and 15 deletions
|
@ -13,9 +13,17 @@ const (
|
|||
ShutdownTimeoutDefault = 30 * time.Second
|
||||
|
||||
// AddressDefault is a default value for metrics HTTP service endpoint.
|
||||
AddressDefault = ""
|
||||
AddressDefault = "localhost:9090"
|
||||
)
|
||||
|
||||
// Enabled returns the value of "enabled" config parameter
|
||||
// from "metrics" section.
|
||||
//
|
||||
// Returns false if the value is missing or invalid.
|
||||
func Enabled(c *config.Config) bool {
|
||||
return config.BoolSafe(c.Sub(subsection), "enabled")
|
||||
}
|
||||
|
||||
// ShutdownTimeout returns the value of "shutdown_timeout" config parameter
|
||||
// from "metrics" section.
|
||||
//
|
||||
|
|
|
@ -17,6 +17,7 @@ func TestMetricsSection(t *testing.T) {
|
|||
|
||||
require.Equal(t, metricsconfig.ShutdownTimeoutDefault, to)
|
||||
require.Equal(t, metricsconfig.AddressDefault, addr)
|
||||
require.False(t, metricsconfig.Enabled(configtest.EmptyConfig()))
|
||||
})
|
||||
|
||||
const path = "../../../../config/example/node"
|
||||
|
@ -27,6 +28,7 @@ func TestMetricsSection(t *testing.T) {
|
|||
|
||||
require.Equal(t, 15*time.Second, to)
|
||||
require.Equal(t, "localhost:9090", addr)
|
||||
require.True(t, metricsconfig.Enabled(c))
|
||||
}
|
||||
|
||||
configtest.ForEachFileType(path, fileConfigTest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue