2021-03-15 13:11:40 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
metricsconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/metrics"
|
2023-05-31 09:25:32 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
2021-03-15 13:11:40 +00:00
|
|
|
)
|
|
|
|
|
2022-11-24 11:36:49 +00:00
|
|
|
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"
|
2023-04-05 08:44:13 +00:00
|
|
|
c.dynamicConfiguration.metrics.handler = metrics.Handler()
|
2022-11-24 11:36:49 +00:00
|
|
|
updated = true
|
2021-03-16 08:14:56 +00:00
|
|
|
}
|
2021-03-15 13:11:40 +00:00
|
|
|
|
2022-11-24 11:36:49 +00:00
|
|
|
// (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
|
|
|
|
}
|
2021-05-11 22:59:05 +00:00
|
|
|
|
2022-11-24 11:36:49 +00:00
|
|
|
return c.dynamicConfiguration.metrics, updated
|
|
|
|
}
|
2021-08-04 14:44:37 +00:00
|
|
|
|
2022-11-24 11:36:49 +00:00
|
|
|
func enableMetricsSvc(c *cfg) {
|
|
|
|
c.shared.metricsSvc.Enable()
|
|
|
|
}
|
2021-08-04 14:44:37 +00:00
|
|
|
|
2022-11-24 11:36:49 +00:00
|
|
|
func disableMetricsSvc(c *cfg) {
|
|
|
|
c.shared.metricsSvc.Disable()
|
2021-03-15 13:11:40 +00:00
|
|
|
}
|