Volume 6 · Chapter 9 — Observability and Operations

X-Ray and OpenTelemetry in Depth

Goutham Mayaluri 4 min read AWSCloudX-RayObservability

9.1 Introduction

The tracing chapter introduced X-Ray; the exam and real deployments require more - the anatomy of traces (segments, subsegments), sampling to control cost, annotations and metadata for filtering, and the modern OpenTelemetry approach via the AWS Distro (ADOT). This chapter provides that depth for instrumenting distributed systems.

9.2 Segments, Subsegments, and the Service Map

An X-Raytracerepresents one request’s end-to-end path, composed ofsegments(the work done by each service) andsubsegments(finer detail within a segment, like a specific downstream call or database query). X-Ray assembles these into aservice map- a visual graph of services and dependencies annotated with latency and error rates - so you see the topology and spot the slow or failing node at a glance. Instrumentation comes from the X-Ray SDK or, increasingly, OpenTelemetry, and for some services (like API Gateway, ALB, Lambda) tracing integrates natively. The segment/subsegment model is what lets a trace pinpointexactlywhich downstream call in which service caused latency.

flowchart LR
  Trace[Trace - one request] --> S1[Segment: API service]
  S1 --> Sub1[Subsegment: DB query]
  S1 --> S2[Segment: payment service]
  S2 --> Sub2[Subsegment: external call]
  Map[Service map: nodes + latency + error %] -.built from.-> Trace

9.3 Sampling, Annotations, and Groups

At scale, tracing every request is costly and unnecessary, so X-Ray usessampling- a configurable rule (e.g. the first request per second plus a percentage of the rest) captures a representative subset while keeping overhead and cost low.Annotationsare indexed key-value data added to traces that you canfilter and searchby (e.g. customer tier, transaction type), whilemetadatais non-indexed extra detail.Groupslet you define subsets of traces by filter expression for focused analysis and their own service maps. These features make tracing affordable and queryable at production scale - you sample to control cost, annotate to slice by business dimensions, and group to focus on a subset (like only failed payments).

9.4 OpenTelemetry and ADOT

The industry standard for telemetry isOpenTelemetry (OTel)- a vendor-neutral set of APIs and a collector for metrics, logs, and traces. AWS provides theAWS Distro for OpenTelemetry (ADOT), a supported OTel distribution that collects traces and metrics and exports them to X-Ray, CloudWatch, and third-party backends. Using ADOT/OpenTelemetry avoids lock-in to a single vendor’s SDK and standardizes instrumentation across languages and destinations. The exam pattern: OpenTelemetry (via ADOT) is the modern, vendor-neutral instrumentation that can feed X-Ray and CloudWatch, so you’re not tied to proprietary agents - increasingly the recommended approach over service-specific SDKs.

9.5 Banking Production Scenario

A bank instruments its microservices with OpenTelemetry via ADOT, exporting traces to X-Ray and metrics to CloudWatch, avoiding vendor lock-in. Each request’s trace shows segments per service and subsegments for database and external-payment-network calls, and the service map highlights any slow or erroring dependency. Sampling keeps tracing overhead and cost low at high volume, while annotations tag traces with transaction type and customer tier so engineers filter for, say, only failed high-value payments. A group isolates traces of the payment flow for focused analysis. Correlation IDs tie traces to logs, and ServiceLens unifies the view. When latency spikes, the team follows the service map and traces to the exact slow subsegment in minutes. This professional-grade distributed tracing is exactly what the certification expects.

9.6 Chapter Revision Notes

  • A trace = one request; segments (per service) and subsegments (per call/query) build the service map (topology + latency + error rates).
  • Sampling captures a representative subset to control tracing cost/overhead at scale.
  • Annotations = indexed, filterable key-values (slice by business dimension); metadata = non-indexed detail; groups = trace subsets by filter with their own maps.
  • OpenTelemetry (via AWS Distro for OpenTelemetry, ADOT) is the vendor-neutral standard, exporting to X-Ray, CloudWatch, and third parties - avoids lock-in.
  • Tie traces to logs via correlation IDs; ServiceLens unifies metrics, logs, and traces per service.