A developer is troubleshooting a distributed application. The flow begins with an Amazon API Gateway HTTP API that integrates with an AWS Lambda function. The Lambda function performs some processing and sends an HTTP request to an internal Java-based microservice running on Amazon ECS on AWS Fargate behind an Application Load Balancer (ALB). The Java microservice then writes records to an Amazon DynamoDB table.
Active tracing is enabled on both the API Gateway and the Lambda function. However, in the AWS X-Ray console, the developer observes that:
1. The trace map shows the Lambda function's execution segment, but the Java microservice and the subsequent DynamoDB calls are represented as a separate, disconnected trace map.
2. The DynamoDB calls themselves are missing from the X-Ray service map entirely.
Which two actions should the developer take to resolve these issues and establish continuous, end-to-end trace propagation?
- In the Lambda function's code, ensure the outgoing HTTP client is instrumented with the AWS X-Ray SDK, or manually retrieve the current trace entity and inject the X-Amzn-Trace-Id header into the HTTP request sent to the ALB.Cevap
- In the ECS task definition, add a container definition for the aws-xray-daemon, ensure the ECS task role has the xray:PutTraceSegments and xray:PutTelemetryRecords permissions, and configure the Java microservice's AWS SDK clients with the X-Ray SDK's TracingInterceptor.Cevap
- CConfigure the ECS task execution role with the xray:PutTraceSegments permission, and configure the Java application to send tracing segments directly to the ALB's DNS name using the X-Ray daemon cluster-wide endpoint.
- DChange the API Gateway integration type to a Lambda custom integration, and configure a mapping template to extract the X-Amzn-Trace-Id header from API Gateway and pass it as a JSON payload property to the Lambda handler.
- EIncrease the Lambda function's timeout and memory settings to allow the execution context to remain warm long enough for the X-Ray SDK to buffer and flush tracing segments to the daemon before the function container terminates.