1. A company is migrating a critical application to AWS Lambda functions and Amazon API Gateway. They need to implement distributed tracing to monitor the performance of individual Lambda invocations and their interactions with downstream services, such as Amazon DynamoDB and external APIs. The solution should provide a visual service map and detailed trace data to identify latency bottlenecks. The developers want to minimize manual instrumentation. Which approach should be used?
Monitoring and Logging
- A. Enable CloudWatch Logs for Lambda and API Gateway, and use CloudWatch Logs Insights to analyze invocation durations.
- B. Configure API Gateway to enable X-Ray tracing and enable active tracing for Lambda functions.
- C. Instrument each Lambda function with custom code to send trace data to an external OpenTelemetry collector.
- D. Deploy custom metrics to CloudWatch using the Embedded Metric Format (EMF) for each Lambda function and DynamoDB table.
Show answerAnswer
B. Configure API Gateway to enable X-Ray tracing and enable active tracing for Lambda functions.
AWS X-Ray is purpose-built for distributed tracing across serverless and microservices architectures. By enabling X-Ray tracing directly on API Gateway and setting Lambda functions to 'active tracing,' X-Ray automatically captures trace data, generates a service map, and provides detailed timing information for each segment, including calls to downstream AWS services like DynamoDB, with minimal manual instrumentation.