diff --git a/CHANGELOG.md b/CHANGELOG.md index 422c17e7d..a52ef9add 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cmd/s3-gw/app.go b/cmd/s3-gw/app.go index d8da913db..7ea81515b 100644 --- a/cmd/s3-gw/app.go +++ b/cmd/s3-gw/app.go @@ -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. diff --git a/metrics/app.go b/metrics/app.go index 4de4317eb..c757617fe 100644 --- a/metrics/app.go +++ b/metrics/app.go @@ -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() diff --git a/metrics/state.go b/metrics/state.go index 9d28c5b62..e4317ac28 100644 --- a/metrics/state.go +++ b/metrics/state.go @@ -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)) }