A developer has deployed a Python web application on an Amazon EC2 instance. The developer wants to use AWS X-Ray to trace incoming HTTP requests and downstream AWS service calls. Which two actions must the developer take to instrument the application and successfully send trace data to X-Ray? (Select TWO.)
- Install and run the AWS X-Ray daemon on the Amazon EC2 instance to collect and upload trace data.Answer
- Use the AWS X-Ray SDK to patch supported libraries in the Python code to record outgoing HTTP and AWS SDK calls.Answer
- CInitialize the AWS SDK clients by hardcoding an IAM user's access keys that have permissions to write trace segments.
- DRely solely on enabling active tracing in the EC2 console, which automatically instruments the application code without SDK configuration.
- EConfigure a custom execution timeout on the Amazon EC2 instance configuration to allow the Lambda environment to flush trace segments.
Answer
Install and run the AWS X-Ray daemon on the Amazon EC2 instance to collect and upload trace data, and use the AWS X-Ray SDK to patch supported libraries in the Python code to record outgoing HTTP and AWS SDK calls.
For an application hosted on an Amazon EC2 instance to use AWS X-Ray, the host must run the X-Ray daemon to collect and forward trace segment documents to the AWS X-Ray API. Additionally, the application code must use the AWS X-Ray SDK to patch outgoing libraries (such as boto3) to capture downstream context and API calls.
Step-by-Step Solution
Key Concept
To enable X-Ray tracing on Amazon EC2, the developer must manually install and run the X-Ray daemon and instrument the application code using the X-Ray SDK.