2020-07-06 09:18:16 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-07-21 14:42:24 +00:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
2020-07-06 09:18:16 +00:00
|
|
|
|
2022-07-21 14:42:24 +00:00
|
|
|
const (
|
|
|
|
namespace = "neofs_s3_gw"
|
|
|
|
stateSubsystem = "state"
|
2020-07-06 09:18:16 +00:00
|
|
|
)
|
|
|
|
|
2022-07-21 14:42:24 +00:00
|
|
|
type GateMetrics struct {
|
|
|
|
stateMetrics
|
2020-07-12 23:00:47 +00:00
|
|
|
}
|
|
|
|
|
2022-07-21 14:42:24 +00:00
|
|
|
type stateMetrics struct {
|
|
|
|
healthCheck prometheus.Gauge
|
|
|
|
}
|
|
|
|
|
|
|
|
func newGateMetrics() *GateMetrics {
|
|
|
|
stateMetric := newStateMetrics()
|
|
|
|
stateMetric.register()
|
|
|
|
|
|
|
|
return &GateMetrics{
|
|
|
|
stateMetrics: stateMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newStateMetrics() stateMetrics {
|
|
|
|
return stateMetrics{
|
|
|
|
healthCheck: prometheus.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Namespace: namespace,
|
|
|
|
Subsystem: stateSubsystem,
|
|
|
|
Name: "health",
|
|
|
|
Help: "Current S3 gateway state",
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m stateMetrics) register() {
|
|
|
|
prometheus.MustRegister(m.healthCheck)
|
|
|
|
}
|
2020-07-06 09:18:16 +00:00
|
|
|
|
2022-07-21 14:42:24 +00:00
|
|
|
func (m stateMetrics) SetHealth(s int32) {
|
|
|
|
m.healthCheck.Set(float64(s))
|
2020-07-06 09:18:16 +00:00
|
|
|
}
|