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.)
- 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.Answer
- Use the AWS X-Ray SDK in the application code to wrap the DynamoDB client and capture trace context for downstream calls.Answer
- CCreate a configuration file in a folder named `ebextensions` (without the leading dot) at the root of the application source bundle to enable X-Ray.
- DInitialize the AWS X-Ray SDK by hardcoding the AWS access key and secret access key of an IAM user directly in the application code.
- EIncrease the Amazon SQS visibility timeout to allow the X-Ray daemon sufficient time to process and upload trace data.
Answer
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.
Step-by-Step Solution
Key Concept
Instrumenting Elastic Beanstalk applications with the AWS X-Ray daemon and capturing downstream AWS SDK client calls.
Estimated Time:2m 0s