ProLesson 12.2Intermediate3 min readUpdated 31 October 2026
Distributed Tracing with Micrometer & OpenTelemetry
Trace asynchronous requests across microservice boundaries using TraceId, SpanId, W3C TraceContext headers, and Micrometer Tracing in Spring Boot 3.
While structured logs tell you what code executed, they cannot visualize where a request spent its latency.
If an API response takes 2,400 milliseconds, did the delay occur:
- In the API Gateway?
- In the database query?
- In an outbound call to a third-party payment partner?
Distributed Tracing solves this by recording an end-to-end timeline of every network hop and internal method execution.
01Anatomy of a Distributed Trace: TraceId vs SpanId
A distributed trace forms a directed acyclic graph (DAG) of Spans:
Key Definitions:
- Trace: The overall end-to-end journey of a single transaction across all microservices. It is identified by a globally unique
TraceId. - Span: A discrete, continuous segment of work within a single service (e.g. an HTTP request, a database query, or an event publish). Each span has:
SpanId: Unique identifier for this unit of work.ParentSpanId: Points to the calling span that triggered this work.- Timing: Start timestamp, duration, and completion timestamp.
- Tags / Attributes: Key-value metadata (e.g.
http.status_code=200,db.statement="SELECT...").
Loading the rest of the lesson…