Spring Cloud Sleuth was a library that added distributed tracing to Spring applications by creating trace and span IDs, putting them in the logs and propagating them across HTTP calls and messages. It is no longer maintained: it supported Spring Boot 2.x only, and Spring Boot 3 replaced it with Micrometer Tracing.
If you are starting a new project or upgrading to Boot 3 or later, use Micrometer Tracing with a Brave or OpenTelemetry bridge. The concepts below are the same in both.
In a microservice system one user request may pass through a gateway, three services and a database. When it is slow or fails, logs from each service are separate and hard to connect. Distributed tracing gives the whole request a shared identity.
| Term | Meaning |
|---|---|
| Trace | The full journey of one request, identified by a trace ID |
| Span | One unit of work inside the trace, such as an HTTP call or a database query, with its own span ID |
| Propagation | Passing the IDs to the next service in headers (W3C traceparent or B3) |
| Sampling | Deciding which traces are recorded and exported |
With the IDs in every log line you can search for one trace ID and see the request across all services.
Sleuth auto-instrumented Spring Boot 2.x applications. It added the trace and span IDs to the logging MDC, so a log line looked like this:
It also instrumented RestTemplate, WebClient, Feign, messaging and scheduled tasks, and reported spans to Zipkin. Under the hood it used Brave, the tracer library from the Zipkin project.
Spring moved tracing into the Micrometer project so that metrics and traces share one observability API. The Sleuth project did not get a Spring Boot 3 release. Its core was moved to Micrometer Tracing, and applications now use the Observation API. Staying on Sleuth means staying on Spring Boot 2.x, which has also reached the end of open source support, so migration is the sensible path.
Add Actuator and a tracer bridge, and an exporter for the backend you use. With Brave and Zipkin:
For OpenTelemetry, use micrometer-tracing-bridge-otel with an OTLP exporter such as opentelemetry-exporter-otlp. Then configure sampling and the endpoint:
The default sampling probability is 0.1, so only 10 percent of requests are traced. Set it to 1.0 while developing. Boot auto-configures instrumentation for RestClient, RestTemplate and WebClient only when you create them from the injected builders, so inject RestClient.Builder or WebClient.Builder instead of calling new.
You can observe your own code through the Observation API, which feeds both metrics and traces:
Spring also supports the @Observed annotation on beans when AOP is on the classpath and an ObservedAspect bean is registered.
spring-cloud-starter-sleuth and spring-cloud-sleuth-zipkin.spring.sleuth.sampler.probability becomes management.tracing.sampling.probability.Tracer and @NewSpan code with Micrometer's Tracer or the Observation API.Only on Spring Boot 2.x, which is no longer supported. For anything current, use Micrometer Tracing.
No. Zipkin is one backend. You can also send traces by OTLP to Jaeger, Grafana Tempo or a vendor product.
Yes, when the messaging clients are instrumented through Spring's observation support, the context travels in message headers.
The trace ID is shared by the entire request across services. Each span ID identifies one operation within that trace.
Spring Cloud Sleuth gave Spring Boot 2.x applications distributed tracing, but it is retired. Use Micrometer Tracing with a Brave or OpenTelemetry bridge on Spring Boot 3 and later, keep trace IDs in your logs, and sample sensibly in production.