From 8154bab9229039db611f1cdc36b7c3c4b46f5ab4 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Mon, 9 May 2016 17:30:00 +0200 Subject: [PATCH] Added docs on how to add Sleuth to the project --- README.adoc | 220 +++++++++++++++++- docs/src/main/asciidoc/intro.adoc | 208 ++++++++++++++++- .../ZipkinStreamServerApplication.java | 2 +- 3 files changed, 424 insertions(+), 6 deletions(-) diff --git a/README.adoc b/README.adoc index 929ea1e4d..3ab3686af 100644 --- a/README.adoc +++ b/README.adoc @@ -145,11 +145,227 @@ filter { === Adding to the project -In general if you want to profit only from Spring Cloud Sleuth without the Zipkin integration just add -the *spring-cloud-starter-sleuth* module to your project. +==== Only Sleuth (log correlation) + +If you want to profit only from Spring Cloud Sleuth without the Zipkin integration just add +the *spring-cloud-starter-sleuth1 module to your project. + +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] +.Maven +---- + <1> + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RC2 + pom + import + + + + + <2> + org.springframework.cloud + spring-cloud-starter-sleuth + +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-starter-sleuth` + +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] +.Gradle +---- +dependencyManagement { <1> + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RC2" + } +} + +dependencies { <2> + compile "org.springframework.cloud:spring-cloud-starter-sleuth" +} +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-starter-sleuth` + +==== Sleuth with Zipkin via HTTP If you want both Sleuth and Zipkin just add the *spring-cloud-starter-zipkin* dependency. +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] +.Maven +---- + <1> + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RC2 + pom + import + + + + + <2> + org.springframework.cloud + spring-cloud-starter-zipkin + +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-starter-zipkin` + +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] +.Gradle +---- +dependencyManagement { <1> + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RC2" + } +} + +dependencies { <2> + compile "org.springframework.cloud:spring-cloud-starter-zipkin" +} +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-starter-zipkin` + +==== Sleuth with Zipkin via Spring Cloud Stream + +If you want both Sleuth and Zipkin just add the `spring-cloud-sleuth-stream` dependency. + +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] +.Maven +---- + <1> + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RC2 + pom + import + + + + + <2> + org.springframework.cloud + spring-cloud-sleuth-stream + + + <3> + org.springframework.cloud + spring-cloud-stream-binder-rabbit + +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-sleuth-stream` +<3> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to + +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] +.Gradle +---- +dependencyManagement { <1> + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RC2" + } +} + +dependencies { + compile "org.springframework.cloud:spring-cloud-sleuth-stream" <2> + // Example for Rabbit binding + compile "org.springframework.cloud:spring-cloud-stream-binder-rabbit" <3> +} +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-sleuth-stream` +<3> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to + +==== Spring Cloud Sleuth Stream Zipkin Collector + +If you want to start a Spring Cloud Sleuth Stream Zipkin collector just add the `spring-cloud-sleuth-zipkin-stream` +dependency + +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] +.Maven +---- + <1> + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RC2 + pom + import + + + + + <2> + org.springframework.cloud + spring-cloud-sleuth-zipkin-stream + + + <3> + org.springframework.cloud + spring-cloud-stream-binder-rabbit + +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-sleuth-zipkin-stream` +<3> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to + +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] +.Gradle +---- +dependencyManagement { <1> + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RC2" + } +} + +dependencies { + compile "org.springframework.cloud:spring-cloud-sleuth-zipkin-stream" <2> + // Example for Rabbit binding + compile "org.springframework.cloud:spring-cloud-stream-binder-rabbit" <3> +} +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-sleuth-zipkin-stream` +<3> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to + +and then just annotate your main class with `@EnableZipkinStreamServer` annotation: + +[source,java] +---- +package example; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.sleuth.zipkin.stream.EnableZipkinStreamServer; + +@SpringBootApplication +@EnableZipkinStreamServer +public class ZipkinStreamServerApplication { + + public static void main(String[] args) throws Exception { + SpringApplication.run(ZipkinStreamServerApplication.class, args); + } + +} +---- + == Features * Adds trace and span ids to the Slf4J MDC, so you can extract all the logs from a given trace or span in a log aggregator. Example logs: diff --git a/docs/src/main/asciidoc/intro.adoc b/docs/src/main/asciidoc/intro.adoc index b038b5471..7f7922c61 100644 --- a/docs/src/main/asciidoc/intro.adoc +++ b/docs/src/main/asciidoc/intro.adoc @@ -137,7 +137,209 @@ filter { === Adding to the project -In general if you want to profit only from Spring Cloud Sleuth without the Zipkin integration just add -the *spring-cloud-starter-sleuth* module to your project. +==== Only Sleuth (log correlation) -If you want both Sleuth and Zipkin just add the *spring-cloud-starter-zipkin* dependency. \ No newline at end of file +If you want to profit only from Spring Cloud Sleuth without the Zipkin integration just add +the *spring-cloud-starter-sleuth1 module to your project. + +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] +.Maven +---- + <1> + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RC2 + pom + import + + + + + <2> + org.springframework.cloud + spring-cloud-starter-sleuth + +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-starter-sleuth` + +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] +.Gradle +---- +dependencyManagement { <1> + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RC2" + } +} + +dependencies { <2> + compile "org.springframework.cloud:spring-cloud-starter-sleuth" +} +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-starter-sleuth` + +==== Sleuth with Zipkin via HTTP + +If you want both Sleuth and Zipkin just add the *spring-cloud-starter-zipkin* dependency. + +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] +.Maven +---- + <1> + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RC2 + pom + import + + + + + <2> + org.springframework.cloud + spring-cloud-starter-zipkin + +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-starter-zipkin` + +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] +.Gradle +---- +dependencyManagement { <1> + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RC2" + } +} + +dependencies { <2> + compile "org.springframework.cloud:spring-cloud-starter-zipkin" +} +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-starter-zipkin` + +==== Sleuth with Zipkin via Spring Cloud Stream + +If you want both Sleuth and Zipkin just add the `spring-cloud-sleuth-stream` dependency. + +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] +.Maven +---- + <1> + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RC2 + pom + import + + + + + <2> + org.springframework.cloud + spring-cloud-sleuth-stream + + + <3> + org.springframework.cloud + spring-cloud-stream-binder-rabbit + +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-sleuth-stream` +<3> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to + +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] +.Gradle +---- +dependencyManagement { <1> + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RC2" + } +} + +dependencies { + compile "org.springframework.cloud:spring-cloud-sleuth-stream" <2> + // Example for Rabbit binding + compile "org.springframework.cloud:spring-cloud-stream-binder-rabbit" <3> +} +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-sleuth-stream` +<3> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to + +==== Spring Cloud Sleuth Stream Zipkin Collector + +If you want to start a Spring Cloud Sleuth Stream Zipkin collector just add the `spring-cloud-sleuth-zipkin-stream` +dependency + +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] +.Maven +---- + <1> + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RC2 + pom + import + + + + + <2> + org.springframework.cloud + spring-cloud-sleuth-zipkin-stream + + + <3> + org.springframework.cloud + spring-cloud-stream-binder-rabbit + +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-sleuth-zipkin-stream` +<3> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to + +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] +.Gradle +---- +dependencyManagement { <1> + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RC2" + } +} + +dependencies { + compile "org.springframework.cloud:spring-cloud-sleuth-zipkin-stream" <2> + // Example for Rabbit binding + compile "org.springframework.cloud:spring-cloud-stream-binder-rabbit" <3> +} +---- +<1> In order not to pick versions by yourself it's much better if you add the dependency management via +the Spring BOM +<2> Add the dependency to `spring-cloud-sleuth-zipkin-stream` +<3> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to + +and then just annotate your main class with `@EnableZipkinStreamServer` annotation: + +[source,java] +---- +include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-sleuth/master/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/src/main/java/example/ZipkinStreamServerApplication.java[] +---- diff --git a/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/src/main/java/example/ZipkinStreamServerApplication.java b/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/src/main/java/example/ZipkinStreamServerApplication.java index 0cbf30128..4551e4086 100644 --- a/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/src/main/java/example/ZipkinStreamServerApplication.java +++ b/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/src/main/java/example/ZipkinStreamServerApplication.java @@ -12,4 +12,4 @@ public class ZipkinStreamServerApplication { SpringApplication.run(ZipkinStreamServerApplication.class, args); } -} +} \ No newline at end of file