Question

Difficulty: EasyInstrumenting Distributed Tracing with AWS X-Ray

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.)

  1. Instrument the application code by wrapping the AWS SDK client with the AWS X-Ray SDK.Answer
  2. Add the AWS X-Ray daemon container as a sidecar container in the Amazon ECS task definition.Answer
  3. C
    Initialize the AWS SDK clients by hardcoding AWS access keys and secret keys inside the Node.js application configuration files.
  4. D
    Configure custom API Gateway mapping templates to extract the X-Ray trace headers and pass them as environment variables to the container.
  5. E
    Modify 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

1
Wrap the AWS SDK client with the AWS X-Ray SDK inside the Node.js application code.
The application code is instrumented to capture downstream AWS calls as trace segments.
Without code instrumentation, the AWS SDK will not generate trace data for outbound service calls.
2
Define an AWS X-Ray daemon container in the task definition to run as a sidecar alongside the application container.
A local X-Ray daemon is running and listening on UDP port 2000 within the same ECS task.
The X-Ray SDK sends trace data to the local daemon, which buffers and uploads the traces to the AWS X-Ray service.

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.
Rate this question