All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mework.cloud.spring-cloud-sleuth-docs.3.1.7.source-code.README.adoc Maven / Gradle / Ivy

:jdkversion: 1.8

image::https://github.com/spring-cloud/spring-cloud-sleuth/workflows/Build/badge.svg?style=svg["Build",link="https://github.com/spring-cloud/spring-cloud-sleuth/actions"]
image::https://badges.gitter.im/spring-cloud/spring-cloud-sleuth.svg[Gitter,link="https://gitter.im/spring-cloud/spring-cloud-sleuth?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"]

== Spring Cloud Sleuth

=== !!!! IMPORTANT !!!!

Spring Cloud Sleuth's last minor version is 3.1. You can check the https://github.com/spring-cloud/spring-cloud-sleuth/tree/3.1.x[3.1.x] branch for the latest commits.

WARNING: Spring Cloud Sleuth will not work with Spring Boot 3.x onward. The last major version of Spring Boot that Sleuth will support is 2.x.

The core of this project got moved to https://micrometer.io/docs/tracing[Micrometer Tracing] project and the instrumentations will be moved to https://micrometer.io/[Micrometer] and all respective projects (no longer all instrumentations will be done in a single repository.

You can check the https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide[Micrometer Tracing migration guide] to learn how to migrate from Spring Cloud Sleuth to Micrometer Tracing.

=== Introduction

Spring Cloud Sleuth provides Spring Boot auto-configuration for distributed tracing.

Sleuth configures everything you need to get started.
This includes where trace data (spans) are reported to, how many traces to keep (sampling), if remote fields (baggage) are sent, and which libraries are traced.

=== Quick Start

Add Spring Cloud Sleuth to the classpath of a Spring Boot application (together with a Tracer implementation) and you will see trace IDs in logs.
Example of Sleuth with Brave tracer:

[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
	
	
		
			
				org.springframework.cloud
				spring-cloud-dependencies
				
				${release.train.version}
				pom
				import
			
		
	

	
		
		
			org.springframework.boot
			spring-boot-starter-web
		
		
		
			org.springframework.cloud
			spring-cloud-starter-sleuth
		
	
----

Consider the following HTTP handler:

[source,java,indent=0]
----
@RestController
public class DemoController {
	private static Logger log = LoggerFactory.getLogger(DemoController.class);

	@RequestMapping("/")
	public String home() {
		log.info("Handling home");
		return "Hello World";
	}
}
----

If you add that handler to a controller, you can see the calls to `home()`
being traced in the logs (notice the `0b6aaf642574edd3` ids).

[indent=0]
----
2020-10-21 12:01:16.285  INFO [,0b6aaf642574edd3,0b6aaf642574edd3,true] 289589 --- [nio-9000-exec-1] DemoController	          : Handling home!
----

NOTE: Instead of logging the request in the handler explicitly, you could set `logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG`.

NOTE: Set `spring.application.name=myService` (for instance) to see the service name as well as the trace and span IDs.

== Documentation

Please visit the https://docs.spring.io/spring-cloud-sleuth/docs/[documentation page] to read more about the project.

== Building

include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/building.adoc[]

== Contributing

include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/contributing.adoc[]




© 2015 - 2024 Weber Informatics LLC | Privacy Policy