# Carrying trace context across queues in serverless OpenTelemetry | Chalk talks

Page: https://hallwaywire.com/chalk/914ed8fe54/

Source: Hallway Wire (hallwaywire.com), an independent re:Invent news site. If you quote or reuse this, please credit Hallway Wire and link the page.

[All chalk talks](https://hallwaywire.com/chalk.html)

- **SVS334**  Carrying trace context across queues in serverless OpenTelemetry  Debugging a serverless request that crosses an HTTP entry point, a queue and several functions is hard unless trace context travels with the message, and the board shows how to pass it along.  From the chalk talk “Serverless observability: OpenTelemetry and vended logs”  ![The board](https://hallwaywire.com/chalk/914ed8fe54/photo-01-board.jpg)  On the board HTTP entry and first function A request arrives over HTTP and is handled by a function (the left sketch is only partly legible). This is most likely where the trace starts and where the trace ID and parent span are created. Producer function A function in the second sketch does its work and then hands off asynchronously instead of calling the next step directly. It must attach the current trace context to what it sends, or the trace breaks here. Queue hop An SQS queue sits between the producer and the consumers. The notes beneath it say trace context should travel in SQS message attributes rather than in the event body. The queue is the point where traces are most often lost, so this is where the talk spends its time. Consumer functions One or more functions read from the queue, and one is labelled as generating a thumbnail. Each reads the context from the message attributes, so its spans attach to the original trace instead of starting a new one. Where the context rides, per service The notes under the diagram give one rule per hop: for SQS, the trace context goes in message attributes; for EventBridge, it goes in the event detail. Either way the identifiers travel with the message, so the consumer can pick the trace back up instead of starting a new one.  The pattern The design idea is context propagation: every asynchronous hop carries the trace identifiers as metadata, so one request can be followed from the HTTP edge through the queue to the functions that finish the job. Putting the context in message attributes keeps it separate from the payload, so consumers need no knowledge of the producer's data format. The cost is that every producer and consumer must be instrumented to write and read those attributes, and any uninstrumented hop splits the trace in two.  Not legible in the photos: The left-hand sketch of the entry point is too small and blurry to identify its components. The text on the physical whiteboard is not legible, and some labels on the projected diagram, including small annotations near the queue, could not be read.  When work crosses a queue or an event bus, carry the trace context with it: in SQS message attributes, in the EventBridge event detail. Have consumers restore it, so one request stays one trace.  AWS Lambda Amazon SQS Amazon EventBridge  Scouted by Sabiha Ali, Hero

