fix: TRAC-1066 Reset stale queue gauges instead of holding last value#19
Merged
chanceaclark merged 1 commit intoJul 4, 2026
Conversation
Cloudflare's queueBacklogAdaptiveGroups GraphQL analytics endpoint only returns a row for a queue when there was measured activity in that scrape window. When a queue goes idle, it silently disappears from the response, and fetchQueueAnalytics only calls .Set() for queue IDs present in the response — so the gauge freezes at its last non-zero value forever instead of resetting. This caused MakeswiftStencilWorkerQueueBacklogCritical/Warning to fire in production reporting a 17.44k message backlog while the real queue was confirmed empty via wrangler. Thanos showed the metric flatlined at 691 for 13+ hours, then jumped to exactly 17444 and stayed frozen there on both exporter replicas — the signature of a stale gauge, not real queue depth. Drop each account's previous label combinations for all 7 queue gauges before repopulating them each scrape, mirroring the existing pattern in fetchWorkerWAEAnalytics. Idle or deleted queues now disappear from /metrics instead of holding stale values. Fixes TRAC-1066 Co-Authored-By: Claude <noreply@anthropic.com>
chanceaclark
deleted the
chancellorclark/ltrac-1099-fix-stale-cloudflare_queue_backlog_messages-gauge-in
branch
July 4, 2026 18:49
13 tasks
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.
Pull Request Template
Description
Two production alerts (
MakeswiftStencilWorkerQueueBacklogCritical/Warning) fired for themakeswift-stencil-publish-revalidation-production-usqueue, reporting a 17.44k message backlog, while the real queue (confirmed viawrangler) was empty.Root cause: Cloudflare's
queueBacklogAdaptiveGroupsGraphQL analytics endpoint only returns a row for a queue when there was measured activity in that scrape window. When a queue goes idle, it silently disappears from the response.fetchQueueAnalyticsonly calls.Set()for queue IDs present in the response, so the gauge freezes at its last non-zero value forever instead of resetting. Confirmed via Thanos: the metric flatlined at691for 13+ hours, then jumped to exactly17444and stayed frozen there on both exporter replicas — the signature of a stale gauge, not real queue depth.Fix:
fetchQueueAnalyticsnow callsDeletePartialMatch({"account": accountName})on all 7 queue-related gauges (queueBacklogMessages,queueBacklogBytes,queueConsumerConcurrency,queueOperations,queueOperationBytes,queueOperationLagTime,queueOperationRetryCount) before repopulating them each scrape, mirroring the existing pattern already used infetchWorkerWAEAnalyticsforworkerOperationDuration. Idle or deleted queues now disappear from/metricsinstead of holding stale values.Verified the downstream alert rules in
prometheus-alerts/rules/store_cells/trac/makeswift-stencil-worker.yml.erbuse plainmax(metric{...}) > thresholdcomparisons with noabsent()dependency, so a missing series simply won't match — no alerting-rule changes needed.Type of Change
Testing
make pr-testsand all tests passgo build ./...andgofmt -l .are clean, and the pre-commitgolangci-linthook passed.make pr-tests'stesttarget (run_e2e.sh) requires live Cloudflare API credentials via.envandvenom, which weren't run here — recommend CI or a reviewer with credentials confirm/metricsstill serves correctly end-to-end. No unit tests exist forfetchQueueAnalyticsspecifically in this repo today.Manual verification recommended post-deploy: watch
cloudflare_queue_backlog_messages{queue_name="makeswift-stencil-publish-revalidation-production-us"}in Thanos — it should either disappear (queue idle) or track real fluctuating values, not stay pinned at17444.Code Quality
Additional Notes
Jira: TRAC-1066