Use OTel span links to connect causally related spans across asynchronous message queue boundaries

domain: opentelemetry.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. When producing a message, extract the current span context and serialize it into the message headers or attributes using the W3C TraceContext propagator
  2. When consuming the message, extract the producer's span context from the headers using propagator.extract()
  3. Create the consumer span as a new root (do not use the producer context as parent) to keep producer and consumer traces independent and correctly timed
  4. Add a SpanLink from the consumer span to the producer span context: span.addLink({context: producerSpanContext}) with an optional attributes map
  5. In the trace backend (Jaeger, Tempo), use the span link to navigate between the producer and consumer traces for end-to-end request correlation

Known gotchas

Related routes

Use OTel span links to model batch processing and fan-in relationships
opentelemetry.io · 5 steps · unrated
Manually create and nest spans with the OTel SDK to trace internal business logic beyond framework auto-instrumentation
opentelemetry.io · 6 steps · unrated
Implement OTel SDK context propagation across async task boundaries in Python with asyncio and contextvars
opentelemetry.io · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans