A Lambda function behind an API Gateway REST API returns an HTTP 200, but clients sometimes observe 502/504. The function is instrumented with CloudWatch logs. Which approach best preserves end-to-end request context across Lambda retries and helps pinpoint timeout versus downstream errors?
Answer
Configure API Gateway to use X-Ray tracing and enable active tracing in the Lambda function, then correlate segments with API Gateway execution logs
Explanation
Active X-Ray tracing for API Gateway and Lambda preserves request context and segment metadata so you can distinguish timeouts (integration latency) from downstream failures and correlate retries reliably.
Last reviewed: October 2026
Reviewed by FirstInTest Editorial Team
Related questions
In an API backed by Lambda, you sometimes see cold-start latency spikes and inconsistent response times. You need deterministic performance for request handling while keeping cost controlled. Which strategy is most aligned with the Lambda execution model and can be implemented as a developer?
View question →
You publish events to EventBridge and process them with a Lambda that updates a DynamoDB item. Some events are delivered more than once. You must guarantee that processing is effectively once per event for a given aggregate. Which approach is most appropriate?
View question →
You must implement idempotent order creation in a service that receives repeated POST requests from clients. You can use DynamoDB. Which design most directly satisfies at-least-once delivery while preventing duplicate orders?
View question →
You must process large files uploaded to S3. After upload, you want to trigger processing only for objects that have a specific metadata flag set, and you must avoid processing partially uploaded objects. What event-driven approach fits best?
View question →
When implementing a streaming upload to S3 from a client, you need to minimize memory usage and ensure integrity checks are performed without loading the entire payload. The client sends chunks and includes an overall checksum. Which approach is most appropriate?
View question →
A service receives requests that must update multiple DynamoDB tables as a single logical unit. You cannot use distributed transactions. What is the most robust pattern to maintain consistency with eventual convergence?
View question →