Carry the trace context in the job payload
A trace stops at the queue: the producer's span closes on enqueue, and the worker opens a fresh one with no parent.
import { context, propagation } from "@opentelemetry/api";
const carrier = {};
propagation.inject(context.active(), carrier); // sets traceparent
await enqueue({ ...payload, carrier });
context.with(propagation.extract(context.active(), job.carrier), run); // workerThe carrier is a plain object, so it serialises with the payload and the worker's span lands in the caller's trace. If the job runs hours later, link the spans instead of nesting them.
opentelemetryobservabilityqueues