A developer is deploying a Node.js application to Amazon ECS using the AWS Fargate launch type. The application calls downstream AWS services using the AWS SDK. The developer needs to configure distributed tracing with AWS X-Ray for this containerized application. Which two actions must the developer take to instrument the application and enable trace data collection? (Select TWO.)
- Instrument the application code by wrapping the AWS SDK client with the AWS X-Ray SDK.Answer
- Add the AWS X-Ray daemon container as a sidecar container in the Amazon ECS task definition.Answer
- CInitialize the AWS SDK clients by hardcoding AWS access keys and secret keys inside the Node.js application configuration files.
- DConfigure custom API Gateway mapping templates to extract the X-Ray trace headers and pass them as environment variables to the container.
- EModify the Amazon SQS queue visibility timeout to be lower than the X-Ray segment propagation timeout to prevent loss of tracing segments.
Answer
Instrumenting the application code by wrapping the AWS SDK client with the AWS X-Ray SDK, and adding the AWS X-Ray daemon container as a sidecar container in the Amazon ECS task definition are both required.
To enable distributed tracing for a Node.js application running on ECS Fargate, two main configurations are necessary: first, instrumenting the application code by wrapping the AWS SDK client to generate segment data, and second, configuring the X-Ray daemon as a sidecar container in the task definition to receive and forward these traces.
Step-by-Step Solution
Key Concept
Instrumenting distributed tracing for containerized applications on ECS requires both application-level code instrumentation using the AWS X-Ray SDK and deploying the X-Ray daemon as a sidecar container.