forked from TrueCloudLab/frostfs-node
Alex Vanin
20de74a505
Due to source code relocation from GitHub. Signed-off-by: Alex Vanin <a.vanin@yadro.com>
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
metricsconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/metrics"
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
)
|
|
|
|
func metricsComponent(c *cfg) (*httpComponent, bool) {
|
|
var updated bool
|
|
// check if it has been inited before
|
|
if c.dynamicConfiguration.metrics == nil {
|
|
c.dynamicConfiguration.metrics = new(httpComponent)
|
|
c.dynamicConfiguration.metrics.cfg = c
|
|
c.dynamicConfiguration.metrics.name = "metrics"
|
|
c.dynamicConfiguration.metrics.handler = promhttp.Handler()
|
|
updated = true
|
|
}
|
|
|
|
// (re)init read configuration
|
|
enabled := metricsconfig.Enabled(c.appCfg)
|
|
if enabled != c.dynamicConfiguration.metrics.enabled {
|
|
c.dynamicConfiguration.metrics.enabled = enabled
|
|
updated = true
|
|
}
|
|
address := metricsconfig.Address(c.appCfg)
|
|
if address != c.dynamicConfiguration.metrics.address {
|
|
c.dynamicConfiguration.metrics.address = address
|
|
updated = true
|
|
}
|
|
dur := metricsconfig.ShutdownTimeout(c.appCfg)
|
|
if dur != c.dynamicConfiguration.metrics.shutdownDur {
|
|
c.dynamicConfiguration.metrics.shutdownDur = dur
|
|
updated = true
|
|
}
|
|
|
|
return c.dynamicConfiguration.metrics, updated
|
|
}
|
|
|
|
func enableMetricsSvc(c *cfg) {
|
|
c.shared.metricsSvc.Enable()
|
|
}
|
|
|
|
func disableMetricsSvc(c *cfg) {
|
|
c.shared.metricsSvc.Disable()
|
|
}
|