frostfs-s3-gw/metrics/http.go

35 lines
834 B
Go
Raw Normal View History

package metrics
import "github.com/prometheus/client_golang/prometheus"
const (
serverSubsystem = "server"
httpHealthMetric = "health"
)
type httpServerMetrics struct {
endpointHealth *prometheus.GaugeVec
}
func newHTTPServerMetrics() *httpServerMetrics {
return &httpServerMetrics{
endpointHealth: mustNewGaugeVec(appMetricsDesc[serverSubsystem][httpHealthMetric]),
}
}
func (m *httpServerMetrics) Collect(ch chan<- prometheus.Metric) {
m.endpointHealth.Collect(ch)
}
func (m *httpServerMetrics) Describe(desc chan<- *prometheus.Desc) {
m.endpointHealth.Describe(desc)
}
func (m *httpServerMetrics) MarkHealthy(endpoint string) {
m.endpointHealth.WithLabelValues(endpoint).Set(float64(1))
}
func (m *httpServerMetrics) MarkUnhealthy(endpoint string) {
m.endpointHealth.WithLabelValues(endpoint).Set(float64(0))
}