A developer is troubleshooting a containerized Node.js application deployed on Amazon ECS with AWS Fargate. The application calls an external third-party API for address validation and writes records to an Amazon DynamoDB table. The developer configured the AWS X-Ray daemon as a sidecar container in the ECS task definition. While DynamoDB tracing is working correctly, the external API calls do not appear on the X-Ray service map, and trace context is lost for downstream transactions.
Which two actions should the developer take to resolve these issues and ensure complete distributed tracing? (Select TWO.)
- Use the AWS X-Ray SDK Express middleware to capture incoming HTTP requests and establish the parent segment context.Answer
- Use the AWS X-Ray SDK to wrap the Node.js HTTP/HTTPS module using captureHTTPsGlobal to instrument downstream HTTP calls.Answer
- CAdd the AWSXRayDaemonWriteAccess policy to the ECS Task Execution Role to permit trace data transmission.
- DInitialize the AWS SDK client inside the application by hardcoding temporary IAM access keys obtained from the container metadata service.
- EConfigure the SQS visibility timeout of any downstream queue to be longer than the API Gateway integration timeout to prevent trace segments from splitting.
Answer
To enable complete distributed tracing, the developer must use the AWS X-Ray SDK Express middleware to capture incoming HTTP requests and establish the parent segment context, and use the AWS X-Ray SDK to wrap the Node.js HTTP/HTTPS module using captureHTTPsGlobal to instrument downstream HTTP calls.
Establishing incoming request context via Express middleware and wrapping outgoing HTTP client libraries with the AWS X-Ray SDK ensure that trace IDs are generated, propagated, and associated correctly. This enables the complete trace path to appear on the X-Ray service map.
Step-by-Step Solution
Key Concept
Instrumenting distributed tracing for containerized applications involves initializing incoming request middleware to manage trace context and wrapping downstream HTTP clients to propagate the tracing header.