0

at my app, I was able to track all the lambda, APIGateway and DynamoDB requests through AWS-X-Ray.

I am doing the same as the answer in this question:

Adding XRAY Tracing to non-rest functions e.g., SQS, Cognito Triggers etc

However, how would be the case of S3, SQS or other services/non-rest functions ?? I saw some old code that does not even use aws-sdk, the dependencies are import direct like:

import {S3Client, S3Address, RoleService, SQSService} from '@sws/aws-bridge';

So, in these cases, how to integrate/activate AWS-XRay?

Thank you very much in advance!

Cheers,

Marcelo

Turtles
  • 234
  • 3
  • 13
  • In case of SQS, there is nothing you need to set explicitly. If you use an instrumented client (e.g. SNS client that uses X-Ray) that publishes to an SNS topic, then the message is sent to a subscribed SQS queue, it will be traced as it travels through your system. Same goes for S3 – Vangelisz Ketipisz Jul 14 '21 at 17:55

1 Answers1

1

At the moment Lambda doesn't support continuing traces from triggers other than REST APIs or direct invocation

The upstream service can be an instrumented web application or another Lambda function. Your service can invoke the function directly with an instrumented AWS SDK client, or by calling an API Gateway API with an instrumented HTTP client.

In every other case it will create its own, new Trace ID and use that instead.

You can work around this yourself by creating a new AWS-Xray segment inside the Lambda Function and using the incoming TraceID from the event. 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.

Sam Martin
  • 1,238
  • 10
  • 19