Skip to content

feat(run-engine,webapp): always report worker queue length metrics#4028

Closed
ericallam wants to merge 3 commits into
hotfix-base/worker-queue-length-metricfrom
hotfix/worker-queue-length-metric
Closed

feat(run-engine,webapp): always report worker queue length metrics#4028
ericallam wants to merge 3 commits into
hotfix-base/worker-queue-length-metricfrom
hotfix/worker-queue-length-metric

Conversation

@ericallam

Copy link
Copy Markdown
Member

Summary

The runqueue.workerQueue.length gauge only reported a worker queue's depth while runs were being dequeued from it. When dequeues stop, the metric goes stale or missing, so a queue that has backed up because nothing is draining it can't be alerted on. This adds a small observer that refreshes the observed set of worker queues from the WorkerInstanceGroup records on an interval, so every active worker queue (and its scheduled split variant) keeps reporting its length regardless of dequeue activity.

The observer is off by default and enabled per service via RUN_ENGINE_WORKER_QUEUE_OBSERVER_ENABLED, reads from the read replica, and skips a configurable set of cloud providers (RUN_ENGINE_WORKER_QUEUE_OBSERVER_EXCLUDED_CLOUD_PROVIDERS, default digitalocean). When enabled it is the source of truth for the observed set, so the per-dequeue registration is skipped on that instance.

Also removes the unused GET/POST /api/v1/workers endpoints. Their only consumer was a CLI command group that is no longer registered.

Notes for reviewers

This PR targets an older release commit rather than main, so the diff is exactly this change and nothing else; the equivalent change for main will follow as a separate PR. Verified end to end against a local stack: the gauge reports each worker queue's length with no dequeues happening, excludes the configured providers, includes hidden groups, and the removed endpoints return as if they never existed.

The runqueue.workerQueue.length gauge only observed worker queues that a
dequeue had registered, so a queue's depth stopped being reported once
dequeues stopped (or was never reported for a queue that backed up before
anything dequeued from it). A periodic observer now refreshes the observed
set from the WorkerInstanceGroup records instead, so every active worker
queue (and its scheduled split variant) keeps reporting its length
regardless of dequeue activity. Off by default; enable per-service via an
env var. Reads from the replica and skips configured cloud providers.
The GET and POST /api/v1/workers endpoints backed a CLI command group that
is no longer registered, so they had no reachable consumer. Remove them.
… timeout

Disable the execution workers and batch consumers in the worker queue
observation test. It only needs enqueue + processMasterQueue + the observer
gauge, and the extra workers add Redis connections and make engine.quit()
hang on worker shutdown when the shard's Redis is under pressure, timing the
test out in CI.
@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7821c3a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4cb1c3aa-66a3-4643-9e0a-c7ccc63dac49

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/worker-queue-length-metric

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@ericallam

Copy link
Copy Markdown
Member Author

Superseded: shipping this as a normal PR into main instead of a hotfix (see the new PR). Closing this and the throwaway prod-commit base branch.

@ericallam ericallam closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant