Soru

Zorluk: ZorInstrumenting Distributed Tracing with AWS X-Ray

A Go-based web application is running on Amazon EC2 instances inside a private subnet. The application handles incoming user requests and calls a downstream microservice on another EC2 instance via HTTP. The developer has installed the AWS X-Ray daemon on all EC2 instances and wants to implement distributed tracing to monitor end-to-end performance. However, currently, no traces are appearing in the AWS X-Ray console, and the downstream HTTP calls are not being correlated with the upstream web requests.

Which two actions must the developer take to resolve these issues and ensure proper end-to-end tracing?

  1. Attach an IAM role with the AWSXRayDaemonWriteAccess policy to the EC2 instances to allow the X-Ray daemon to upload trace data.Cevap
  2. Use the AWS X-Ray SDK to instrument the HTTP client in the Go application to automatically inject the tracing header into outgoing requests.Cevap
  3. C
    Hardcode a set of IAM user credentials with write access to X-Ray during the initialization of the AWS SDK client in the application code.
  4. D
    Configure a longer visibility timeout on the Amazon SQS queue between the services to prevent duplicate trace segment processing.
  5. E
    Enable Active Tracing in the Amazon EC2 console settings to automatically start the segment propagation across VPC subnets.

Cevap

Attach an IAM role with the AWSXRayDaemonWriteAccess policy to the EC2 instances, and use the AWS X-Ray SDK to instrument the HTTP client in the Go application.
The solution requires addressing both daemon communication permissions and service-to-service context propagation. First, the daemon running on the EC2 instance requires IAM permissions to upload trace segments, which is resolved by granting the AWSXRayDaemonWriteAccess policy to the instance's role. Second, trace context must be forwarded to downstream HTTP services, which is accomplished by wrapping the HTTP client with the X-Ray SDK so it injects the X-Amzn-Trace-Id header into outgoing requests.

Adım Adım Çözüm

1
Configure permissions for the daemon.
The X-Ray daemon can authenticate and push data.
By attaching an IAM role with the AWSXRayDaemonWriteAccess policy to the EC2 instances, the daemon on EC2 obtains the permissions required to make PutTraceSegments API calls to AWS X-Ray.
2
Instrument the HTTP client code using the AWS X-Ray SDK.
The HTTP client automatically appends the tracing header to outgoing calls.
To propagate the trace context across HTTP boundaries, the client must generate and inject the X-Amzn-Trace-Id header into downstream requests.

Anahtar Kavram

To enable distributed tracing on EC2, the developer must ensure the X-Ray daemon has the necessary IAM permissions via an instance profile, and that HTTP clients are instrumented using the X-Ray SDK to propagate tracing context down the service call stack.
Tahmini Süre:2m 30s
Bu soruyu puanla