feat: add trackJobQueueTime helper and job queue context names#330
Open
jrothrock wants to merge 3 commits into
Open
feat: add trackJobQueueTime helper and job queue context names#330jrothrock wants to merge 3 commits into
jrothrock wants to merge 3 commits into
Conversation
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>
…ueue from span.tags()
…5 layers have no .regexp
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
trackJobQueueTime(request, enqueuedAt)to the public API — setsscout.job_queue_time_nsso Scout displays the correct Queue Latency in the Background Jobs UIScoutContextName.JobQueueTimeNS("scout.job_queue_time_ns") andScoutContextName.Queue("queue") to the enumqueue_time.pyCustomers 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 testpassestrackJobQueueTimesetsscout.job_queue_time_nscorrectly for all input types (Date, ms, s, ns)"queue"context is set🤖 Generated with Claude Code