Distributed Tracing Follows a Request Across Services by Propagating a Trace Context
In a distributed system one user request crosses a gateway, several services and a database. Logs and metrics show each piece separately; a trace shows the whole journey with timings, so the slow or failing link stands out. It only works if every service passes the same trace identifier along with the request.
Traces, Spans and Context
- A span is one unit of work (an HTTP handler, a database query) with a start time, a duration and attributes.
- A trace is the tree of spans for one request, linked by parent–child relations.
- Context propagation carries the trace ID and the current span ID from service to service, usually in HTTP headers (the W3C
traceparentheader).
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
version-trace id-parent span id-flags
Getting Spans
Instrumentation creates spans, either automatically (libraries that wrap HTTP servers, clients and database drivers) or manually around business logic. OpenTelemetry is the vendor-neutral standard for that instrumentation and exports traces, metrics and logs to a backend: Jaeger or Zipkin (open source), AWS X-Ray, Datadog APM and others.
What Traces Answer
- Which component makes this request slow?
- Where did this error start, and what called it?
- Does a call fan out into more downstream calls than expected (N+1 queries, retries)?
References
- DevOps and Infrastructure as Code MOC - hub for DevOps and observability notes.
- OpenTelemetry documentation: Traces - spans, traces and context.
- W3C Trace Context - the
traceparentheader format.
Review cards
Flashcard What happens if a service drops the context during a request?
The trace is broken, appearing as two unrelated traces with an invisible gap between them.
Flashcard What carries a trace from one service to the next?
Context propagation: the trace ID and the current span ID travel with the request, usually in the W3C traceparent HTTP header.