简体   繁体   中英

How to use AWS Xray to connect traces across multiple lambda and SQS

We are attempting to use AWS Xray to trace an event through multiple services. We have enabled Xray within lambda via the checkbox and added the python (v2) SDK. This is giving us good information for each lambda, but they are not connected. Here is our model:

  1. event hits SNS
  2. Lambda is triggered for preprocessing writes to SQS
  3. event in SQS
  4. Another Lambda picks up event and processes, writes to another SNS

We can see the python libraries which python is calling by doing the patch_all() .

I was hoping to see connectivity end-to-end but I don't know how to associate these components. Right now we see the Lambdas as independent pieces and nothing for SQS.

Currently X-Ray does not support above use-case and actively working on this. Currently we cannot share ETA on when this will be available.

For more details please see https://forums.aws.amazon.com/thread.jspa?messageID=873142&#873142

Although as Rusty rightly says it is not currently officially supported, you can work around this yourself by creating a new AWS-Xray segment inside the Lambda Function and using the incoming TraceID from the SQS message. This will result in two Segments for your lambda invocation. One which Lambda itself creates, and one which you create to extend the existing trace. Whether that's acceptable or not for your use case is something you'll have to decide for yourself!

If you're working with Python you can do it with aws-xray-lambda-segment-shim .
If you're working with NodeJS you can follow this guide on dev.to .
If you're working with .NET there are some examples on this GitHub issue .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM