"Logs tell you why a request was slow." Not across services. When one click passes through an API, a Lambda function, a queue and a database, each log sees only its own piece. To find the slow or failing hop you need the whole journey of one request. That is distributed tracing, and on AWS it is AWS X-Ray.
Traces, segments and subsegments
- The first instrumented service a request hits creates a trace ID and passes it downstream in the
X-Amzn-Trace-Idheader. Every service that handles the request records against the same ID. - Each service sends a segment: its name, the request, the response, start and end times, and any errors.
- Work inside a service, such as a DynamoDB call, an HTTP call or a SQL query, becomes a subsegment with its own timing.
- All segments with the same trace ID form one trace, shown as a timeline.
You can add annotations (indexed key/value pairs, like customerTier=gold) to search traces later, and metadata for details you don't need to search.
The trace map
X-Ray combines traces into a trace map: a graph of your services and the calls between them, with latency and error rates on each node. A red node or a slow edge tells you where to look, instead of guessing from ten log groups. Trace data is kept for 30 days.
Sampling
Tracing every request can be expensive at scale, so X-Ray samples. The default rule records the first request each second and five percent of additional requests. You can add rules: trace every payment, sample health checks at a very low rate.
Heads-up: SDKs, the daemon and OpenTelemetry
The X-Ray SDKs and the X-Ray daemon entered maintenance mode on February 25, 2026 and reach end of support on February 25, 2027. X-Ray itself keeps accepting traces, but new instrumentation should use OpenTelemetry, through the AWS Distro for OpenTelemetry or upstream OpenTelemetry, with the CloudWatch agent or an OpenTelemetry Collector replacing the daemon. OpenTelemetry spans are converted to X-Ray segments, so traces still appear in the CloudWatch console, alongside Application Signals. If you run old X-Ray SDK code, plan the migration now rather than in February.
Where AI fits
An AI agent is a distributed system in miniature: one question can trigger several model calls, tool calls and retrieval steps. Amazon Bedrock AgentCore Observability traces each step of the agent workflow in OpenTelemetry-compatible format and stores it in CloudWatch, with dashboards for sessions, latency, token usage and errors. When an answer is slow or wrong, you can see whether the time went to the model, a tool, or a retry loop, and inspect the intermediate outputs.
Quick recap
- One trace ID follows a request through every service.
- Segments time each service; subsegments time each call inside it.
- The trace map shows the slow or failing hop; sampling controls cost.
- X-Ray SDKs end support in February 2027: use OpenTelemetry for new code.