Skip to content

feat(redis-worker): add oldest-message-age queue gauge#4086

Merged
0ski merged 2 commits into
mainfrom
oskar/feat-redis-worker-oldest-message-age
Jun 30, 2026
Merged

feat(redis-worker): add oldest-message-age queue gauge#4086
0ski merged 2 commits into
mainfrom
oskar/feat-redis-worker-oldest-message-age

Conversation

@0ski

@0ski 0ski commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Adds a redis_worker.queue.oldest_message_age observable gauge (labeled
worker_name) and SimpleQueue.oldestMessageAge(), reporting the age of the
oldest overdue message in each queue. Generic queue-stall signal: 0 while a
queue drains healthily, rising only when due work sits undrained (blocked
dequeue, dead consumer, backpressure) — even when no items are being processed.

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bc40ac8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 28 packages
Name Type
@trigger.dev/redis-worker Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/plugins Patch
@trigger.dev/python Patch
@trigger.dev/react-hooks Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/rbac Patch
@trigger.dev/sso Patch
trigger.dev Patch
@internal/dashboard-agent Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-store Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/zod-worker Patch
@internal/sdk-compat-tests Patch

Not sure what this means? Click here to learn what changesets are.

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

@0ski 0ski marked this pull request as ready for review June 30, 2026 14:25
@0ski 0ski self-assigned this Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

A new oldestMessageAge(): Promise<number> method is added to SimpleQueue in packages/redis-worker/src/queue.ts. It checks Redis for the oldest due queue entry with an existing payload and returns its age in milliseconds, or 0 for empty, future-only, orphan-only, or error cases. The worker registers a new observable gauge for this value and records it with the worker_name label. Tests cover empty, future-scheduled, overdue, orphaned, and post-dequeue states, and a changeset entry is added.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only includes a short summary and misses the template sections for issue link, checklist, testing, changelog, and screenshots. Add the missing template sections, including Closes #issue, checklist items, testing steps, changelog, and screenshots or mark them N/A.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the new oldest-message-age queue gauge.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch oskar/feat-redis-worker-oldest-message-age

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

@pkg-pr-new

pkg-pr-new Bot commented Jun 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@bc40ac8

trigger.dev

npm i https://pkg.pr.new/trigger.dev@bc40ac8

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@bc40ac8

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@bc40ac8

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@bc40ac8

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@bc40ac8

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@bc40ac8

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@bc40ac8

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@bc40ac8

commit: bc40ac8

coderabbitai[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

0ski added 2 commits June 30, 2026 18:13
Adds a `redis_worker.queue.oldest_message_age_ms` observable gauge (labeled
`worker_name`) and `SimpleQueue.oldestMessageAge()`, reporting the age of the
oldest overdue message in each queue. Generic queue-stall signal: 0 while a
queue drains healthily, rising only when due work sits undrained (blocked
dequeue, dead consumer, backpressure) — even when no items are being processed.
- Drop the _ms suffix from the metric name (keep unit "ms") so the OTLP to
  Prometheus exporter doesn't double-suffix it to _ms_milliseconds.
- Resolve the oldest-overdue candidate against the items hash (new getOldestDueScore
  Lua) so an orphaned queue entry can't report a phantom stall for work that can't
  be dequeued.
@0ski 0ski force-pushed the oskar/feat-redis-worker-oldest-message-age branch from e8aae8a to bc40ac8 Compare June 30, 2026 16:13
@0ski 0ski merged commit c2e2480 into main Jun 30, 2026
47 checks passed
@0ski 0ski deleted the oskar/feat-redis-worker-oldest-message-age branch June 30, 2026 16:41
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.

2 participants