Skip to content

feat: add trackJobQueueTime helper and job queue context names#330

Open
jrothrock wants to merge 3 commits into
bump/core-agent-v1.5.1from
feature/job-queue-time
Open

feat: add trackJobQueueTime helper and job queue context names#330
jrothrock wants to merge 3 commits into
bump/core-agent-v1.5.1from
feature/job-queue-time

Conversation

@jrothrock
Copy link
Copy Markdown
Collaborator

Summary

  • Adds trackJobQueueTime(request, enqueuedAt) to the public API — sets scout.job_queue_time_ns so Scout displays the correct Queue Latency in the Background Jobs UI
  • Adds ScoutContextName.JobQueueTimeNS ("scout.job_queue_time_ns") and ScoutContextName.Queue ("queue") to the enum
  • Helper normalizes any timestamp format (Date, ms, seconds, ns) — same ambiguous-timestamp logic as the Python agent's queue_time.py

Customers must instrument their own job workers manually (no BullMQ/Agenda integration); this gives them the primitives to do it correctly.

Docs: scoutapp/scout-documentation#219
Closes #288

Test plan

  • npm test passes
  • Verify trackJobQueueTime sets scout.job_queue_time_ns correctly for all input types (Date, ms, s, ns)
  • Confirm queue name appears in Background Jobs UI when "queue" context is set

🤖 Generated with Claude Code

Adds a trackJobQueueTime(request, enqueuedAt) helper that calculates
queue latency from an enqueued-at timestamp and tags the request with
scout.job_queue_time_ns — the value Scout uses to populate the
"Queue Latency" column in the background jobs UI.

Also adds ScoutContextName.JobQueueTimeNS and ScoutContextName.Queue
so callers can tag the queue name without hardcoding the string.

The helper accepts Date, milliseconds, seconds, or nanoseconds — same
ambiguous-timestamp normalization the Python agent uses in
scout_apm/core/queue_time.py — so customers don't need to think about
unit conversion. Closes #288.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jrothrock jrothrock changed the base branch from master to bump/core-agent-v1.5.1 May 30, 2026 00:23
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.

Sending additional information for background jobs

1 participant