Soru

Zorluk: ZorInstrumenting Distributed Tracing with AWS X-Ray

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

  1. Use the AWS X-Ray SDK Express middleware to capture incoming HTTP requests and establish the parent segment context.Cevap
  2. Use the AWS X-Ray SDK to wrap the Node.js HTTP/HTTPS module using captureHTTPsGlobal to instrument downstream HTTP calls.Cevap
  3. C
    Add the AWSXRayDaemonWriteAccess policy to the ECS Task Execution Role to permit trace data transmission.
  4. D
    Initialize the AWS SDK client inside the application by hardcoding temporary IAM access keys obtained from the container metadata service.
  5. E
    Configure the SQS visibility timeout of any downstream queue to be longer than the API Gateway integration timeout to prevent trace segments from splitting.

Cevap

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.

Adım Adım Çözüm

1
Add the AWS X-Ray SDK Express middleware to the Node.js application.
Incoming HTTP requests are intercepted, a parent segment is initialized, and the tracing context is set.
Without parent segment context initialized for incoming requests, any downstream subsegments created during external calls will fail to associate correctly.
2
Wrap the HTTP/HTTPS core modules using the AWS X-Ray SDK's captureHTTPsGlobal method.
Outgoing HTTP requests to the third-party API are instrumented, creating subsegments and appending the tracing header.
Unwrapped HTTP client calls are not intercepted by the SDK, preventing trace details from being sent to X-Ray and losing trace correlation.

Anahtar Kavram

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.
Bu soruyu puanla