X-Ray
In modern microservices or serverless architectures, requests typically travel across multiple components and services. It’s difficult to pinpoint “which request is slow?”, “where’s the bottleneck?”, or “where did the error occur?” using logs alone.
- Track the full lifecycle of a request across multiple AWS services.
- Visualize the execution flow and timing with a service map.
- Identify performance bottlenecks, failures, and latency issues.
- Debug production issues without digging through logs manually.
1. Enable X-Ray for Lambda
- Go to AWS Console → Lambda
- Choose your desired Lambda function
- In Monitoring and operations tools, enable Lambda service traces
2. Enable X-Ray for API Gateway
- Already configured in the Logging & Tracing setup step (see section 3)
3. View Service Map
- Navigate to Lambda → select the function
- Click Monitor tab
- Click View X-Ray Traces

4. Trace Individual Requests

- Select any trace to view detailed flow:

✨ Trace Flow:
- Shows flow from Client → API Gateway → Lambda Function
- POST request to
UserAPI/Create
, Lambda processes and returns 201 - Shows timing (66ms) and each component involved

📊 Segments Timeline:
- UserAPI/Create (API Gateway Stage): Received POST, took ~48ms
- Lambda Invoke: Called
create_user
function, took ~44ms - Lambda Execution: Actual logic took ~20ms + 19ms overhead
- Total response time: ~66ms, status code 201 (success)
⚠️ Trace with Errors
