feat: add BullMQ integration#355
Open
jrothrock wants to merge 2 commits into
Open
Conversation
Instruments BullMQ Worker job processing with Scout APM spans. Each job
gets a Job/{name} span with queue, task_id, priority, and queue time
context. Error flag is set when the processor throws.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Required for the e2e test to compile — bullmq types are shipped by the package itself so no @types/* entry is needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Adds Scout APM instrumentation for BullMQ Worker job processing via a
require-time shim onWorker.prototype.callProcessJob.What's instrumented
Each job processed by a BullMQ Worker is wrapped in a Scout transaction + span with the operation name
Job/{jobName}. The following context is attached to every span:queuetask_idpriority"unknown"if unset)scout.job_queue_time_nserror"true"if the processor throwsImplementation approach
The shim patches
Worker.prototype.callProcessJob(BullMQ's internal method that dispatches a single job to the user-provided processor). This is the narrowest possible hook point — it fires once per job execution regardless of concurrency settings, and it's the right place to measure end-to-end job duration including any internal BullMQ overhead before the processor runs.Changes
lib/integrations/bullmq.ts— newBullMQIntegrationclasslib/integrations/index.ts— registersbullmqinKNOWN_PACKAGESandgetIntegrationForPackagelib/types/enum.ts— addsScoutContextName.TaskId,ScoutContextName.Priority, andScoutSpanOperation.BullMQJobtest/integrations/bullmq.e2e.ts— e2e tests covering span creation, queue/task_id/priority/queue_time context, and error flagTest plan
Job/{name}span is created for each processed jobqueue,task_id,priority, andscout.job_queue_time_nscontext values are present and correcterror: "true"is set on the span when the processor throwsnode_test_appsbullmq demo app and confirmJob/spans appear in Scout APM UI🤖 Generated with Claude Code