Soru

Zorluk: OrtaInstrumenting Distributed Tracing with AWS X-Ray

A developer is deploying a Node.js web application to AWS Elastic Beanstalk. The application reads and writes data to an Amazon DynamoDB table using the AWS SDK for JavaScript. The developer wants to use AWS X-Ray to perform distributed tracing of incoming HTTP requests and downstream DynamoDB calls. Currently, the application is running, but no trace data is visible in the AWS X-Ray console.

Which two actions should the developer take to instrument the application and enable distributed tracing? (Select two.)

  1. Create a configuration file in the `.ebextensions` directory at the root of the application source bundle to set `XRayEnabled` to `true` under the `aws:elasticbeanstalk:xray` namespace.Cevap
  2. Use the AWS X-Ray SDK in the application code to wrap the DynamoDB client and capture trace context for downstream calls.Cevap
  3. C
    Create a configuration file in a folder named `ebextensions` (without the leading dot) at the root of the application source bundle to enable X-Ray.
  4. D
    Initialize the AWS X-Ray SDK by hardcoding the AWS access key and secret access key of an IAM user directly in the application code.
  5. E
    Increase the Amazon SQS visibility timeout to allow the X-Ray daemon sufficient time to process and upload trace data.

Cevap

Enable X-Ray tracing in the Elastic Beanstalk environment using a configuration file in the `.ebextensions` directory, and instrument the DynamoDB client in the application code using the AWS X-Ray SDK.
To trace incoming requests and downstream database calls on AWS Elastic Beanstalk, you must enable the X-Ray daemon on the hosting instances and instrument the database client. Creating a configuration file in the `.ebextensions` directory at the root of the source bundle with `XRayEnabled: true` ensures that the platform automatically installs, runs, and updates the X-Ray daemon. Additionally, wrapping the DynamoDB client with the AWS X-Ray SDK enables the capture of downstream calls as subsegments under the active trace context.

Adım Adım Çözüm

1
Enable the AWS X-Ray daemon in the Elastic Beanstalk environment.
The X-Ray daemon is installed and started on the Elastic Beanstalk EC2 instances, listening on local UDP port 2000.
Elastic Beanstalk does not run the X-Ray daemon by default. Creating a configuration file in the `.ebextensions` folder with the `XRayEnabled` option set to `true` instructs Elastic Beanstalk to configure and run the daemon process.
2
Instrument the downstream AWS SDK DynamoDB client using the AWS X-Ray SDK in the application code.
The application wraps the DynamoDB client, allowing the X-Ray SDK to record and inject trace propagation headers into outgoing requests.
Simply enabling the daemon only collects EC2 instance metadata and application container level data. To trace specific downstream calls (like DynamoDB queries), the AWS SDK client must be explicitly instrumented by the X-Ray SDK.

Anahtar Kavram

Instrumenting Elastic Beanstalk applications with the AWS X-Ray daemon and capturing downstream AWS SDK client calls.
Tahmini Süre:2m 0s
Bu soruyu puanla