forked from TrueCloudLab/frostfs-s3-gw
[#91] Update values for health metric
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
a5c89b78bc
commit
17b8905b24
4 changed files with 16 additions and 4 deletions
|
@ -29,6 +29,7 @@ This document outlines major changes between releases.
|
||||||
- Limit number of objects to delete at one time (TrueCloudLab#37)
|
- Limit number of objects to delete at one time (TrueCloudLab#37)
|
||||||
- CompleteMultipartUpload handler now sends whitespace characters to keep alive client's connection (#60)
|
- CompleteMultipartUpload handler now sends whitespace characters to keep alive client's connection (#60)
|
||||||
- Support new system attributes (#64)
|
- Support new system attributes (#64)
|
||||||
|
- Changed values for `frostfs_s3_gw_state_health` metric (#91)
|
||||||
|
|
||||||
## [0.26.0] - 2022-12-28
|
## [0.26.0] - 2022-12-28
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,7 @@ func (a *App) initAPI(ctx context.Context) {
|
||||||
|
|
||||||
func (a *App) initMetrics() {
|
func (a *App) initMetrics() {
|
||||||
a.metrics = metrics.NewAppMetrics(a.log, frostfs.NewPoolStatistic(a.pool), a.cfg.GetBool(cfgPrometheusEnabled))
|
a.metrics = metrics.NewAppMetrics(a.log, frostfs.NewPoolStatistic(a.pool), a.cfg.GetBool(cfgPrometheusEnabled))
|
||||||
|
a.metrics.SetHealth(metrics.HealthStatusStarting)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) initResolver() {
|
func (a *App) initResolver() {
|
||||||
|
@ -369,7 +370,7 @@ func (a *App) Wait() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) setHealthStatus() {
|
func (a *App) setHealthStatus() {
|
||||||
a.metrics.SetHealth(1)
|
a.metrics.SetHealth(metrics.HealthStatusReady)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serve runs HTTP server to handle S3 API requests.
|
// Serve runs HTTP server to handle S3 API requests.
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (m *AppMetrics) SetEnabled(enabled bool) {
|
||||||
m.mu.Unlock()
|
m.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *AppMetrics) SetHealth(status int32) {
|
func (m *AppMetrics) SetHealth(status HealthStatus) {
|
||||||
if !m.isEnabled() {
|
if !m.isEnabled() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ func (m *AppMetrics) SetHealth(status int32) {
|
||||||
func (m *AppMetrics) Shutdown() {
|
func (m *AppMetrics) Shutdown() {
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
if m.enabled {
|
if m.enabled {
|
||||||
m.gate.State.SetHealth(0)
|
m.gate.State.SetHealth(HealthStatusShuttingDown)
|
||||||
m.enabled = false
|
m.enabled = false
|
||||||
}
|
}
|
||||||
m.gate.Unregister()
|
m.gate.Unregister()
|
||||||
|
|
|
@ -4,6 +4,16 @@ import "github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
const stateSubsystem = "state"
|
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 {
|
type stateMetrics struct {
|
||||||
healthCheck prometheus.Gauge
|
healthCheck prometheus.Gauge
|
||||||
}
|
}
|
||||||
|
@ -27,6 +37,6 @@ func (m stateMetrics) unregister() {
|
||||||
prometheus.Unregister(m.healthCheck)
|
prometheus.Unregister(m.healthCheck)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m stateMetrics) SetHealth(s int32) {
|
func (m stateMetrics) SetHealth(s HealthStatus) {
|
||||||
m.healthCheck.Set(float64(s))
|
m.healthCheck.Set(float64(s))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue