Skip to main content
The Queue instrumentation traces the full lifecycle of queued jobs — from dispatch to execution — and propagates trace context across process boundaries so that producer and consumer spans are linked in the same trace.

How It Works

1

Job Dispatched (PRODUCER span)

When a job is dispatched, a PRODUCER span is created with the span name send {queue} (e.g. send default). The current trace context is serialised and stored in the job payload so it can be recovered by the worker process.
2

Job Executed (CONSUMER span)

When the worker picks up the job, the trace context is extracted from the payload and a CONSUMER span is created as a child of the original producer span. The span is named process {queue} (e.g. process default).
This two-span model follows the OpenTelemetry messaging semantic conventions and allows you to visualise end-to-end latency from dispatch through to completion.

Span Attributes

Both producer and consumer spans include the following attributes where available:
AttributeDescription
messaging.systemThe queue driver (e.g. redis, sqs, database).
messaging.operation.typesend for producer, process for consumer.
messaging.message.idThe job UUID.
messaging.destination.nameThe queue name.
messaging.message.envelope_sizeSize of the job payload in bytes.
messaging.message.job_nameThe fully-qualified job class name.
messaging.message.attemptsNumber of attempts.
messaging.message.max_triesMaximum allowed attempts.
messaging.message.timeoutJob timeout in seconds.

Failed Jobs

If a job fails, the exception is recorded on the consumer span and the span status is set to ERROR.

Configuration

In config/opentelemetry.php:
use Keepsuit\LaravelOpenTelemetry\Instrumentation;

'instrumentation' => [
    Instrumentation\QueueInstrumentation::class => env('OTEL_INSTRUMENTATION_QUEUE', true),
],
This instrumentation does not have additional sub-options; it is either enabled or disabled.
Trace context is propagated automatically via the job payload. No changes to your job classes are required.

Disabling

Set the environment variable to false to disable this instrumentation:
OTEL_INSTRUMENTATION_QUEUE=false
Alternatively, remove QueueInstrumentation::class from the instrumentation array in config/opentelemetry.php.

Build docs developers (and LLMs) love