feat: publish durable queue and spool gauges

This commit is contained in:
2026-09-11 09:28:54 +00:00
parent ea8a4d8846
commit 0e18af02bb
7 changed files with 178 additions and 0 deletions
+22
View File
@@ -109,6 +109,7 @@ func run(configPath string) error {
}
recoveryContext, cancelRecovery := context.WithCancel(context.Background())
defer cancelRecovery()
go publishServerTelemetry(recoveryContext, persistence, health)
// Recovery is deliberately asynchronous: liveness and incident inspection
// remain available while committed-range checks run. Readiness becomes
// true only after the real SQLite/segment recovery completes.
@@ -239,3 +240,24 @@ func run(configPath string) error {
return httpErr
}
}
func publishServerTelemetry(ctx context.Context, persistence *store.Store, health *observability.Health) {
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
for {
sampleContext, cancel := context.WithTimeout(ctx, time.Second)
telemetry, err := persistence.Telemetry(sampleContext)
cancel()
if err != nil {
health.Inc("telemetry_read_failure")
} else {
health.SetGauge("queue_depth", float64(telemetry.QueuedCommands))
health.SetGauge("server_charged_bytes", float64(telemetry.ChargedBytes))
}
select {
case <-ctx.Done():
return
case <-ticker.C:
}
}
}