Question #880
A developer is building a serverless application using Python on AWS with AWS Lambda and Amazon API Gateway. The developer uses AWS X-Ray for tracing but notices that some Lambda function invocations are not appearing in the X-Ray traces.
What should the developer do to ensure all Lambda function invocations are recorded in X-Ray?
Configure the X-Ray daemon to run in active mode and increase the UDP packet size for trace data transmission.
Instrument the Lambda functions by using the X-Ray SDK for Python and ensure the Lambda execution role grants X-Ray write permissions.
Enable X-Ray tracing integration directly in the API Gateway stage settings for all API methods.
Reduce the X-Ray segment document size limit in the X-Ray console to improve trace aggregation efficiency.
Explanation
Answer B is correct because AWS Lambda requires both the X-Ray SDK integration and proper IAM permissions to send trace data to X-Ray. Instrumenting the Lambda functions with the X-Ray SDK ensures that custom traces and metadata are captured, while the execution role's X-Ray write permissions (e.g., AWSXRayDaemonWriteAccess) allow the function to transmit data to X-Ray.
Option A is incorrect because the X-Ray daemon is managed by AWS Lambda when Active Tracing is enabled, and UDP settings are not typically user-configurable. Option C is incorrect because enabling X-Ray in API Gateway traces only the API Gateway layer, not the Lambda invocations. Option D is irrelevant, as segment size adjustments do not address missing invocations but rather trace data size limits.
Answer
The correct answer is: B