Skip to content
Theme:

Propagate AWS X-Ray tracing header to the Lambda from SQS, SNS and DynamoDB stream

I faced a challenge where I wanted to propagate AWS X-Ray tracing X-Amzn-Trace-Id header from one Lambda through DynamoDB stream triggered by put operation up to another Lambda. The documentation doesn’t cover working with AWS X-Ray and DynamoDB, but I found the answer in the “Amazon SQS and AWS X-Ray” section that follows a very similar flow. If you’re facing a similar challenge in your project, I have bad news. This integration is currently impossible.

It is not currently possible to connect a trace passed into an SQS queue to the Lambda consuming it on the other end. This is because although the trace header is propagated in the SQS message, you cannot set it in the Lambda because segments in Lambda are immutable.

AWS X-Ray X-Amzn-Trace-Id tracing header flow with SQS, SNS and DynamoDB flow

If you expect a better level of traceability of your service, for now, the only option is to use a third party service.The Epsagon Service Map is what I used and it worked great for me, but I know that Datadog comes with a similar feature. Fingers crossed that AWS X-Ray will become more powerful in the future, as it would be nice to have a sufficient level of tracing and not to leave AWS world.

Comments

  • Z
    Zee

    All you need is to store the X-Amzn-Trace-Id value as an attribute in your JSON and pass it everywhere you need to.

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!

Leave a comment

👆 you can use Markdown here

Your comment is awaiting moderation. Thanks!