Quick revision
The short answer
In Spring Boot 3 and later, Micrometer Tracing records spans through the Observation API and hands them to a tracer bridge, either Brave or OpenTelemetry; it replaced Spring Cloud Sleuth, which only supports Boot 2. Between services, only the trace context is propagated: the trace id, the parent span id and the sampling decision, sent in the W3C traceparent header by default. Boot instruments incoming requests and RestClient, WebClient and RestTemplate built from its builders, and samples 10 percent of traces unless we change management.tracing.sampling.probability.
What to remember
In this answer, we saw that a trace is one request identified by a trace id, made of spans that each have their own id and a parent. In Spring Boot 3 and later, Micrometer Tracing with a Brave or OpenTelemetry bridge replaced Sleuth and creates spans from Spring's observations. Between services only the trace context is propagated, in the W3C traceparent header by default. Boot traces incoming requests and the HTTP clients built from its builders, and it samples 10 percent of traces by default, a value we tune per environment with management.tracing.sampling.probability.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
In Spring Boot 3 and later, Micrometer Tracing records spans through the Observation API and hands them to a tracer bridge, either Brave or OpenTelemetry; it replaced Spring Cloud Sleuth, which only supports Boot 2. Between services, only the trace context is propagated: the trace id, the parent span id and the sampling decision, sent in the W3C traceparent header by default. Boot instruments incoming requests and RestClient, WebClient and RestTemplate built from its builders, and samples 10 percent of traces unless we change management.tracing.sampling.probability.
Why this question is asked
When a request passes through five services and one of them is slow, logs from each service only tell part of the story. Distributed tracing ties the whole journey together, so we can see that the request spent 900 ms waiting on the pricing service. It is often the first observability topic a Spring developer meets, and interviewers ask about it to check that we know the basic vocabulary, what actually travels over the wire, and what changed when Spring moved from Sleuth to Micrometer Tracing. In this answer, we will recap traces and spans, set up tracing in a Boot service, follow a request across two services to see what is propagated, look at what Boot instruments for us, and finish with sampling.
1A Quick Recap of Traces and Spans
A trace is the record of one request as it travels through the system. It is identified by a trace id, a random 128-bit value written as 32 hex characters, which every part of the request shares. A span is one unit of work inside that trace, such as handling the HTTP request in service A or calling service B. Each span has its own 64-bit span id, a start and end time, attributes, and the id of its parent span. The first span, with no parent, is the root.
Because every span knows its parent, the tracing backend can rebuild the request as a tree and draw it as a timeline. That timeline is what we look at when we ask where the time went.
2Setting Up Micrometer Tracing
Spring Cloud Sleuth did this job in Boot 2. Its last line, 3.1, does not support Boot 3, and its core moved into Micrometer Tracing, which is a facade, a thin common API, over a real tracer. We choose one bridge, Brave (from the Zipkin project) or OpenTelemetry, and one exporter that sends finished spans to a backend.
Notice that our application code does not change. Spring's HTTP, messaging and data components already create observations, and with a tracer on the classpath the tracing handler turns each one into a span. Property names for the OTLP endpoint have moved between Boot versions, so check your version's reference documentation.
3What Travels Between Services
Spans themselves are never sent from service to service. Each service sends its own spans directly to the tracing backend. What travels with the request is only the trace context, the small piece of data the next service needs to continue the same trace: the trace id, the id of the calling span, which becomes the parent, and a flag that says whether this trace is sampled.
Boot uses the W3C Trace Context format by default, a standard that most tools and languages understand. It puts the context into a single traceparent header. B3, the older Zipkin format, can be chosen with management.tracing.propagation.type=b3 when we must talk to older systems.
8 messages in order. Play them, or step through them one at a time.
Only the context travels with the request; each service exports its own spans.
4What Spring Boot Instruments for Us
Incoming requests to Spring MVC and WebFlux are traced automatically: Boot reads traceparent if present, or starts a new trace. Outgoing calls are traced when the client was built from a builder that Boot configured: RestClient.Builder, WebClient.Builder or RestTemplateBuilder. Those builders already carry the observation registry, so the client adds the traceparent header and creates a client span.
This is the most common reason a trace breaks in two: somebody created the client with new RestTemplate() or RestClient.create(), and the downstream service starts a fresh trace. Boot also puts traceId and spanId into the logging MDC, so log lines can be tied to the trace. Messaging needs an extra switch: for Kafka we enable observation on the template and listeners, because it is off by default.
5Sampling
Recording every span of every request costs network, storage and money. Sampling decides which traces to keep. Boot's default is head-based probability sampling with management.tracing.sampling.probability=0.1, so about one trace in ten is recorded. The decision is made once at the root and carried in the sampled flag of traceparent, so every service either records the whole trace or none of it.
For local development and test environments we usually set 1.0 to see everything. In production the right value depends on traffic and budget: a service with 50 requests per second can afford 100 percent, while one with 20,000 per second may keep 1 percent and rely on a collector with tail-based sampling to keep the interesting failures.
6Follow-up questions
Is the trace id the same as a correlation id?
It plays the same role and can replace a hand-made correlation id, because every log line in every service can carry it. The difference is that a trace id comes with span ids and parent links, so the backend can also rebuild the timeline, which a plain correlation id cannot do.
What is baggage?
Baggage is extra key-value data that travels with the trace context, such as a tenant id, sent in a baggage header. Micrometer Tracing only propagates the fields we list in management.tracing.baggage.remote-fields, and it can copy them into the MDC with correlation fields. It is sent on every call, so it should stay small and never hold secrets.
Can Brave and OpenTelemetry services talk to each other?
Yes, as long as they agree on the propagation format. With W3C traceparent on both sides, a Brave-based service and an OpenTelemetry-based one continue the same trace. Problems appear when one side still uses B3 only, so on mixed platforms it is worth making W3C the standard everywhere.
7Conclusion
In this answer, we saw that a trace is one request identified by a trace id, made of spans that each have their own id and a parent. In Spring Boot 3 and later, Micrometer Tracing with a Brave or OpenTelemetry bridge replaced Sleuth and creates spans from Spring's observations. Between services only the trace context is propagated, in the W3C traceparent header by default. Boot traces incoming requests and the HTTP clients built from its builders, and it samples 10 percent of traces by default, a value we tune per environment with management.tracing.sampling.probability.
Open with
In Boot 3 and later, tracing is done by Micrometer Tracing, which replaced Spring Cloud Sleuth. Micrometer Tracing is a facade, and I add a bridge to either Brave or OpenTelemetry plus an exporter, for example OTLP to a collector.
Then, if they want more
A trace is one request end to end, identified by a 128-bit trace id, and it's made of spans, each with its own span id and the id of its parent, so the backend can rebuild the tree and show where the time went.
Between services, the spans themselves aren't sent; only the context is propagated: trace id, parent span id and whether the trace is sampled. By default Boot uses the W3C traceparent header, and B3 can be configured for older systems.
Boot instruments incoming requests automatically and outgoing calls from RestClient, WebClient and RestTemplate when they're built from the builders Boot provides, so creating a client with new is the classic way to break a trace. It also puts traceId and spanId into the MDC for logs.
Sampling defaults to 0.1, so ten percent of traces, set with management.tracing.sampling.probability; I'd use 1.0 in test environments and choose a production value based on traffic and cost.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Boot 3
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Cloud documentation, Resilience4j documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How does distributed tracing work in Spring Boot 3 and later with Micrometer Tracing?...": https://scrivio-interview-library.netlify.app/spring-boot/observability/194389f831/