[#91] Update values for health metric #93

Merged
dkirillov merged 1 commit from dkirillov/frostfs-s3-gw:feature/91-update_health_metric into master 2023-04-19 14:44:40 +00:00
4 changed files with 16 additions and 4 deletions

View file

@ -29,6 +29,7 @@ This document outlines major changes between releases.
- Limit number of objects to delete at one time (TrueCloudLab#37)
- CompleteMultipartUpload handler now sends whitespace characters to keep alive client's connection (#60)
- Support new system attributes (#64)
- Changed values for `frostfs_s3_gw_state_health` metric (#91)
## [0.26.0] - 2022-12-28

View file

@ -182,6 +182,7 @@ func (a *App) initAPI(ctx context.Context) {
func (a *App) initMetrics() {
a.metrics = metrics.NewAppMetrics(a.log, frostfs.NewPoolStatistic(a.pool), a.cfg.GetBool(cfgPrometheusEnabled))
a.metrics.SetHealth(metrics.HealthStatusStarting)
}
func (a *App) initResolver() {
@ -369,7 +370,7 @@ func (a *App) Wait() {
}
func (a *App) setHealthStatus() {
a.metrics.SetHealth(1)
a.metrics.SetHealth(metrics.HealthStatusReady)
}
// Serve runs HTTP server to handle S3 API requests.

View file

@ -37,7 +37,7 @@ func (m *AppMetrics) SetEnabled(enabled bool) {
m.mu.Unlock()
}
func (m *AppMetrics) SetHealth(status int32) {
func (m *AppMetrics) SetHealth(status HealthStatus) {
if !m.isEnabled() {
return
}
@ -48,7 +48,7 @@ func (m *AppMetrics) SetHealth(status int32) {
func (m *AppMetrics) Shutdown() {
m.mu.Lock()
if m.enabled {
m.gate.State.SetHealth(0)
m.gate.State.SetHealth(HealthStatusShuttingDown)
m.enabled = false
}
m.gate.Unregister()

View file

@ -4,6 +4,16 @@ import "github.com/prometheus/client_golang/prometheus"
const stateSubsystem = "state"
// HealthStatus of the gate application.
type HealthStatus int32
const (
HealthStatusUndefined HealthStatus = 0
HealthStatusStarting HealthStatus = 1
HealthStatusReady HealthStatus = 2
HealthStatusShuttingDown HealthStatus = 3
)
type stateMetrics struct {
healthCheck prometheus.Gauge
}
@ -27,6 +37,6 @@ func (m stateMetrics) unregister() {
prometheus.Unregister(m.healthCheck)
}
func (m stateMetrics) SetHealth(s int32) {
func (m stateMetrics) SetHealth(s HealthStatus) {
m.healthCheck.Set(float64(s))
}