BullMQ

BullMQ

Scout automatically instruments BullMQ Worker job processing — no manual wrapping required. Every job processed by a Worker gets a Job/{name} span in the Background Jobs area of the Scout UI.

Setup

Ensure Scout is initialized before bullmq is required. The simplest way is a dedicated scout.js that you load first:

// scout.js
const { install } = require("@scout_apm/scout-apm");

install({
    name: process.env.SCOUT_NAME || "my-app",
    key: process.env.SCOUT_KEY,
    monitor: true,
});
// worker.js
require("./scout");                    // must come before bullmq
const { Worker } = require("bullmq");

const worker = new Worker("mailers", async (job) => {
    await sendEmail(job.data);
});

That’s it. Scout patches BullMQ at require-time and traces every job automatically.

What Gets Traced

Each job appears as a Job/{jobName} span with the following context attached:

Context key Value
queue BullMQ queue name
task_id BullMQ job ID
priority Job priority ("unknown" if unset)
scout.job_queue_time_ns Time from enqueue to processing start (nanoseconds)
error "true" if the job processor throws

Supported Versions

Scout supports BullMQ v5+.

Manual Instrumentation

If you need to instrument a job queue that Scout doesn’t support automatically, see Background Jobs for the manual BackgroundTransaction approach.