I've added X-ray instrumentation to my lambda(Node.js) and can see all services around it in the trace, but still cannot add the API Gateway calling it to the trace and the service map. Is there anyway to do it?
According to the X-Ray FAQ, X-Ray only supports the following services: EC2, ECS, Lambda, and Elastic Beanstalk. Until X-Ray adds API Gateway support, you won't be able to trace API Gateway calls w/X-Ray.
X-Ray docs say that metadata is added to AWS SDK calls made to AWS services, so you're seeing X-Ray trace data for other AWS services invoked by your Lambda function.
This X-Ray documentation says that API Gateway doesn't send trace data to X-Ray, so you can't use a similar method to what X-Ray provides for AWS SDKs. For instance, if you used X-Ray's PutTraceSegments
operation right before invoking your API Gateway API, you'd end up with two separate traces for each invocation. It looks like you'll have to wait for X-Ray and API Gateway to integrate. Hopefully that happens soon.
A few days ago AWS announced the availability of X-Ray integration into API Gateway, so yes, getting the whole picture including API Gateway in X-Ray is possible now.
To enable the X-Ray integration in API Gateway, you can use the Management Console, the AWS CLI or do direct API calls.
With the management console open the Stage of an API you want to enable the X-Ray integration for, select the "Logs/Tracing" tab and select "Enable X-Ray Tracing" there as shown in the screenshot below:
To enable the X-Ray integration using the AWS CLI instead, the official documentation sums it up pretty nicely:
To use the AWS CLI to enable active X-Ray tracing for an API that's already been deployed, call the update-stage command as follows:
aws apigateway update-stage \ --rest-api-id {rest-api-id} \ --stage-name {stage-name} \ --patch-operations op=replace,path=/tracingEnabled,value=true
After you enabled the X-Ray integration into your API Gateway API Stage, you'll see the API Gateway API Stage show up in the X-Ray service map.
According to the X-Ray FAQ, X-Ray only supports the following services: EC2, ECS, Lambda, and Elastic Beanstalk. Until X-Ray adds API Gateway support, you won't be able to trace API Gateway calls w/X-Ray.
X-Ray docs say that metadata is added to AWS SDK calls made to AWS services, so you're seeing X-Ray trace data for other AWS services invoked by your Lambda function.
This X-Ray documentation says that API Gateway doesn't send trace data to X-Ray, so you can't use a similar method to what X-Ray provides for AWS SDKs. For instance, if you used X-Ray's PutTraceSegments
operation right before invoking your API Gateway API, you'd end up with two separate traces for each invocation. It looks like you'll have to wait for X-Ray and API Gateway to integrate. Hopefully that happens soon.
© 2022 - 2024 — McMap. All rights reserved.