- Install and configure the instrumentation
- Track job dispatch and processing
- Understand producer and consumer spans
Overview
For the full list of required span attributes and what powers the Jobs dashboard, see the Jobs feature page.Installation
Terminal
bullmq >= 5.0.0
With the AdonisJS agent
Registration through
integrations requires AdonisJS agent 2.x. See the migration guide when upgrading from 1.x.bullmq() to config/monocle.ts. Installing the package alone does not activate it.
config/monocle.ts
sampling callback. Pass sampling to bullmq() to override it for BullMQ only. Omit the integration or use bullmq({ enabled: false }) to disable it. See Job Sampling for sampling rules.
Without the AdonisJS agent
Create an instance ofBullMQInstrumentation and call enable(). This must happen before you import or create any BullMQ Queue, Worker, or FlowProducer instances.
instrumentation.ts
Queue.add, Queue.addBulk, FlowProducer.add, FlowProducer.addBulk, and Worker processing calls are automatically instrumented.
example.ts
Configuration
Span linking vs parenting
By default, consumer spans are linked to the producer span. This means they appear as separate traces connected by a link. SetuseProducerSpanAsConsumerParent: true to make the consumer span a child of the producer, keeping them in the same trace.
Spans
Producer spans
Queue.add creates a PRODUCER span named Queue.add {queueName}.
Queue.addBulk creates an INTERNAL parent span named Queue.addBulk {queueName}, with individual PRODUCER child spans for each job (named Job.addJob {queueName}).
FlowProducer.add creates an INTERNAL parent span named FlowProducer.add {queueName}, with child spans for each job in the flow tree.
FlowProducer.addBulk creates an INTERNAL parent span named FlowProducer.addBulk, with child spans per flow.
Consumer spans
Worker processing creates a CONSUMER span named Worker.run {queueName} for each job processed. The span captures job metadata, queue time, and any errors thrown during processing.