2022-07-19 15:16:42 +00:00
|
|
|
package metrics
|
|
|
|
|
2023-05-31 09:25:32 +00:00
|
|
|
import (
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
2022-07-19 15:16:42 +00:00
|
|
|
|
|
|
|
const stateSubsystem = "state"
|
|
|
|
|
2023-06-14 07:05:51 +00:00
|
|
|
type StateMetrics interface {
|
|
|
|
SetHealth(s int32)
|
|
|
|
}
|
|
|
|
|
2022-07-19 15:16:42 +00:00
|
|
|
type stateMetrics struct {
|
2023-05-31 09:25:32 +00:00
|
|
|
healthCheck prometheus.Gauge
|
2022-07-19 15:16:42 +00:00
|
|
|
}
|
|
|
|
|
2023-06-14 07:05:51 +00:00
|
|
|
func newStateMetrics() *stateMetrics {
|
|
|
|
return &stateMetrics{
|
2023-05-31 09:25:32 +00:00
|
|
|
healthCheck: metrics.NewGauge(prometheus.GaugeOpts{
|
2022-07-19 15:16:42 +00:00
|
|
|
Namespace: namespace,
|
|
|
|
Subsystem: stateSubsystem,
|
|
|
|
Name: "health",
|
|
|
|
Help: "Current Node state",
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-14 07:05:51 +00:00
|
|
|
func (m *stateMetrics) SetHealth(s int32) {
|
2023-05-31 09:25:32 +00:00
|
|
|
m.healthCheck.Set(float64(s))
|
2022-07-19 15:16:42 +00:00
|
|
|
}
|