Files
spring-cloud-sleuth/docs/src/main/asciidoc
Marcin Grzejszczak 0ce00291b6 Updated adocs
2020-06-04 15:52:32 +02:00
..
2020-05-29 05:29:12 +00:00
2020-06-04 15:52:32 +02:00
2020-03-03 19:55:07 +01:00
2019-07-29 14:44:47 +02:00
2020-04-09 22:29:44 +08:00
2020-04-09 22:01:45 +08:00
2020-06-02 11:05:13 +02:00
2020-04-09 20:58:20 +08:00
2020-06-04 15:52:32 +02:00
2020-06-04 15:52:32 +02:00

:jdkversion: 1.8
:github-tag: master
:github-repo: spring-cloud/spring-cloud-sleuth

:github-raw: https://raw.githubusercontent.com/{github-repo}/{github-tag}
:github-code: https://github.com/{github-repo}/tree/{github-tag}

image::https://circleci.com/gh/spring-cloud/spring-cloud-sleuth.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-sleuth"]
image::https://codecov.io/gh/spring-cloud/spring-cloud-sleuth/branch/{github-tag}/graph/badge.svg["codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-sleuth"]
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

Spring Cloud Sleuth provides Spring Boot auto-configuration for distributed
tracing. Underneath, Spring Cloud Sleuth is a layer over a tracer library named
https://github.com/openzipkin/brave[Brave].

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 sleuth to the classpath of a Spring Boot application
(see "`<<sleuth-adding-project>>`" for Maven and Gradle examples), and you will
see trace IDs in logs.

For example, consider the following HTTP handler:

[source,java]
----
@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 as well in https://zipkin.io/[Zipkin], if configured.

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.

include::overview.adoc[]

include::features.adoc[]

include::setup.adoc[]

== Building

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

IMPORTANT: Spring Cloud Sleuth uses two different versions of language level. Java 1.7 is used for main sources, and
Java 1.8 is used for tests. When importing your project to an IDE, you should activate the `ide` Maven profile to turn on
Java 1.8 for both main and test sources. You MUST NOT use Java 1.8 features in the main sources. If you do
so, your app breaks during the Maven build.

== Contributing

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