GH-4512: fix(metrics): pilot_queue_depth frozen on headless daemons — refresh only wired to the TUI loop#4515
Merged
Merged
Conversation
…GH-4512) RefreshQueueDepth's only call site lived inside the TUI dashboard's 2s refresh loop, so any daemon running without --dashboard exported a pilot_queue_depth gauge frozen at whatever value was last set. Add a 30s SafeGo ticker in runPollingMode, gated on the same condition that starts /metrics, with an immediate refresh at boot and a clean exit via ctx cancellation. The dashboard's own refresh is untouched.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automated PR created by Pilot for task GH-4512.
Closes #4512
Changes
GitHub Issue GH-4512: fix(metrics): pilot_queue_depth frozen on headless daemons — refresh only wired to the TUI loop
Problem
pilot_queue_depthandpilot_failed_queue_depthare only refreshed by the interactive dashboard's 2-second loop —autopilot.RefreshQueueDepth(store, metrics)has exactly one call site,cmd/pilot/main.go:3094, inside the TUI refresh path (its own doc comment notes it was added there because the gauge previously "read a constant 0").Consequence: any daemon running headless (
pilot start --telegram --githubwithout--dashboard) exports a frozen queue-depth gauge — whatever value was last set, forever. Alerting or dashboards built on it silently lie.This matters now: hosted S2 tenant instances (TASK-405 / saas-roadmap) run headless by design, and fleet observability (S4 C15 "ops Prometheus w/ tenant labels + alarms") will build on exactly these gauges.
Fix
Move queue-depth refresh into the daemon core, independent of the dashboard:
COUNTquery per tick viastore.CountQueuedTasks) in the main daemon lifecycle that callsautopilot.RefreshQueueDepth(store, metrics)whenever metrics are being served, dashboard or not.safeGoper the panic-recovery convention.Acceptance criteria
--dashboard,pilot_queue_depthon/metricstracks queued-task count changes (integration-style test or a unit test on the ticker wiring provingRefreshQueueDepthis called from the non-dashboard path).Refs
cmd/pilot/main.go:3094(sole current call site),internal/autopilot/metrics_queue_depth.go:9-24Planned Steps (execute all in sequence)