frostfs-s3-gw/cmd/s3-gw/app_healthy.go

47 lines
808 B
Go
Raw Normal View History

2020-07-06 09:18:16 +00:00
package main
import (
"github.com/prometheus/client_golang/prometheus"
)
2020-07-06 09:18:16 +00:00
const (
namespace = "neofs_s3_gw"
stateSubsystem = "state"
2020-07-06 09:18:16 +00:00
)
type GateMetrics struct {
stateMetrics
2020-07-12 23:00:47 +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
func (m stateMetrics) SetHealth(s int32) {
m.healthCheck.Set(float64(s))
2020-07-06 09:18:16 +00:00
}