Soru

Zorluk: OrtaInstrumenting Distributed Tracing with AWS X-Ray

A developer is building a worker application running on Amazon ECS with Fargate. The application polls an Amazon SQS queue for messages, downloads the referenced files from Amazon S3, and writes processing metadata to an Amazon DynamoDB table. The ECS task role has the AWSXRayDaemonWriteAccess IAM policy attached, and the X-Ray daemon runs as a sidecar container in the task definition. Although trace segments for S3 and DynamoDB calls are generated, they appear as separate, disconnected traces in the AWS X-Ray console, and the relationship between the SQS message producer and the worker application's processing activities is not correlated. Which two actions must the developer take to resolve this issue and achieve end-to-end distributed tracing?

  1. Extract the AWS X-Ray trace header from the SQS message system attributes in the worker application, and use the SDK to create a segment context using that header as the parent.Cevap
  2. Instrument the AWS SDK clients for S3 and DynamoDB within the worker application code using the AWS X-Ray SDK.Cevap
  3. C
    Enable active tracing in the configuration settings of the Amazon SQS queue in the AWS Management Console.
  4. D
    Attach the AWSXRayDaemonWriteAccess IAM policy to the ECS Task Execution Role instead of the ECS Task Role.
  5. E
    Configure the SQS queue's visibility timeout to be shorter than the worker application's average message processing time.

Cevap

To resolve the disconnected tracing issue, the developer must extract the AWS X-Ray trace header from the SQS message system attributes to propagate the parent tracing context, and instrument the S3 and DynamoDB SDK clients using the AWS X-Ray SDK to capture downstream requests.
The correct actions involve manually extracting the parent trace context from the SQS message system attributes to bridge the tracing gap across the queue, and instrumenting the AWS SDK clients (S3 and DynamoDB) using the AWS X-Ray SDK to record outgoing service calls.

Adım Adım Çözüm

1
Extract the trace header from SQS messages.
The application retrieves the parent trace ID from the message metadata.
This establishes trace context propagation from the producer to the consumer.
2
Initialize the X-Ray SDK segment using the extracted trace header.
The worker application starts a segment nested under the producer's trace.
This links the SQS message production and the message consumption into a single distributed trace.
3
Instrument the AWS SDK clients for S3 and DynamoDB.
Calls to S3 and DynamoDB are captured as subsegments.
This allows X-Ray to record downstream service calls and link them back to the active tracing segment.

Anahtar Kavram

Distributed tracing correlation across asynchronous boundaries (SQS) and downstream SDK client instrumentation with AWS X-Ray.
Bu soruyu puanla