feat: expose graceful drain state
This commit is contained in:
@@ -32,12 +32,26 @@ func (r *Registry) RecordRuntimeConfig(config RuntimeConfig) {
|
||||
r.SetGauge("orbit_shutdown_timeout_seconds", config.ShutdownTimeout.Seconds(), nil)
|
||||
}
|
||||
|
||||
// RecordDraining records whether this process has entered graceful shutdown.
|
||||
// The value is a fixed, node-local gauge: 0 means serving and 1 means draining.
|
||||
func (r *Registry) RecordDraining(draining bool) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
value := 0.0
|
||||
if draining {
|
||||
value = 1
|
||||
}
|
||||
r.SetGauge("orbit_process_draining", value, nil)
|
||||
}
|
||||
|
||||
// initializeProcess is called once by the registry constructor.
|
||||
func (r *Registry) initializeProcess() {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
r.SetGauge("orbit_process_start_time_seconds", float64(r.started.Unix()), nil)
|
||||
r.RecordDraining(false)
|
||||
build := buildinfo.Current()
|
||||
r.SetGauge("orbit_build_info", 1, Labels{"go_version": build.GoVersion, "version": build.Version, "revision": build.Revision})
|
||||
r.RecordProcess()
|
||||
|
||||
Reference in New Issue
Block a user