Skip to content

Commit

Permalink
Deprecates all span transports except spring-cloud-sleuth-zipkin2 (#758)
Browse files Browse the repository at this point in the history
This deprecates span transports in favor of `spring-cloud-sleuth-zipkin2`
which:
* Supports RabbitMQ and Kafka automatically when adding spring-rabbit or spring-kafka deps
* Supports any io.zipkin.reporter2:zipkin-reporter sender, including Amazon X-Ray
* Defaults to zipkin v2 format, but can be configured to use zipkin v1 format as needed

This lowers the amount of maintenance on the project, as discussed in various issues

See #727
See #711
  • Loading branch information
adriancole committed Oct 22, 2017
1 parent bf6c543 commit 808572d
Show file tree
Hide file tree
Showing 27 changed files with 42 additions and 799 deletions.
12 changes: 5 additions & 7 deletions docs/src/main/asciidoc/features.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,17 @@ a baggage element then it will be sent downstream either via HTTP or messaging t
* Provides simple metrics of accepted / dropped spans.
* If `spring-cloud-sleuth-zipkin` then the app will generate and collect Zipkin-compatible traces.
* If `spring-cloud-sleuth-zipkin2` then the app will generate and collect Zipkin-compatible traces.
By default it sends them via HTTP to a Zipkin server on localhost (port 9411).
Configure the location of the service using `spring.zipkin.baseUrl`.
- If you depend on `spring-rabbit` or `spring-kafka` your app will send traces to a broker instead of http.
- Note: `spring-cloud-sleuth-stream` is deprecated and should no longer be used.
* If `spring-cloud-sleuth-stream` then the app will generate and collect traces via https://github.com/spring-cloud/spring-cloud-stream[Spring Cloud Stream].
Your app automatically becomes a producer of tracer messages that are sent over your broker of choice
(e.g. RabbitMQ, Apache Kafka, Redis).
IMPORTANT: If using Zipkin or Stream, configure the percentage of spans exported using `spring.sleuth.sampler.percentage`
IMPORTANT: If using Zipkin, configure the percentage of spans exported using `spring.sleuth.sampler.percentage`
(default 0.1, i.e. 10%). *Otherwise you might think that Sleuth is not working cause it's omitting some spans.*

NOTE: the SLF4J MDC is always set and logback users will immediately see the trace and span ids in logs per the example
above. Other logging systems have to configure their own formatter to get the same result. The default is
`logging.pattern.level` set to `%5p [${spring.zipkin.service.name:${spring.application.name:-}},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]`
(this is a Spring Boot feature for logback users).
*This means that if you're not using SLF4J this pattern WILL NOT be automatically applied*.
*This means that if you're not using SLF4J this pattern WILL NOT be automatically applied*.
114 changes: 21 additions & 93 deletions docs/src/main/asciidoc/intro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ the Spring BOM

==== Sleuth with Zipkin via HTTP

If you want both Sleuth and Zipkin just add the `spring-cloud-starter-zipkin` dependency.
If you want both Sleuth and Zipkin just add the `spring-cloud-starter-zipkin2` dependency.

[source,xml,indent=0,subs="verbatim,attributes",role="primary"]
.Maven
Expand All @@ -299,12 +299,12 @@ If you want both Sleuth and Zipkin just add the `spring-cloud-starter-zipkin` de
<dependency> <2>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<artifactId>spring-cloud-starter-zipkin2</artifactId>
</dependency>
----
<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`
<2> Add the dependency to `spring-cloud-starter-zipkin2`

[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"]
.Gradle
Expand All @@ -316,78 +316,22 @@ dependencyManagement { <1>
}
dependencies { <2>
compile "org.springframework.cloud:spring-cloud-starter-zipkin"
compile "org.springframework.cloud:spring-cloud-starter-zipkin2"
}
----
<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`
<2> Add the dependency to `spring-cloud-starter-zipkin2`

==== Sleuth with Zipkin via Spring Cloud Stream
==== Sleuth with Zipkin via RabbitMQ or Kafka

If you want both Sleuth and Zipkin just add the `spring-cloud-sleuth-stream` dependency.
If you want to use RabbitMQ or Kafka instead of http, add the `spring-rabbit` or `spring-kafka`
dependencies. The default destination name is `zipkin`.

[source,xml,indent=0,subs="verbatim,attributes",role="primary"]
.Maven
----
<dependencyManagement> <1>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${release.train.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency> <2>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-stream</artifactId>
</dependency>
<dependency> <3>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!-- EXAMPLE FOR RABBIT BINDING -->
<dependency> <4>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
----
<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 the dependency to `spring-cloud-starter-sleuth` - that way all dependant dependencies will be downloaded
<4> 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:${releaseTrainVersion}"
}
}
dependencies {
compile "org.springframework.cloud:spring-cloud-sleuth-stream" <2>
compile "org.springframework.cloud:spring-cloud-starter-sleuth" <3>
// Example for Rabbit binding
compile "org.springframework.cloud:spring-cloud-stream-binder-rabbit" <4>
}
----
<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 the dependency to `spring-cloud-starter-sleuth` - that way all dependant dependencies will be downloaded
<4> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to

==== Spring Cloud Sleuth Stream Zipkin Collector
_Note: `spring-cloud-sleuth-stream` is deprecated and incompatible with these destinations_

If you want to start a Spring Cloud Sleuth Stream Zipkin collector just add the `spring-cloud-sleuth-zipkin-stream`
dependency
If you want Sleuth over RabbitMQ add the `spring-cloud-sleuth-starter-zipkin2` and `spring-rabbit`
dependencies.

[source,xml,indent=0,subs="verbatim,attributes",role="primary"]
.Maven
Expand All @@ -406,23 +350,17 @@ dependency
<dependency> <2>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
<artifactId>spring-cloud-sleuth-starter-zipkin2</artifactId>
</dependency>
<dependency> <3>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!-- EXAMPLE FOR RABBIT BINDING -->
<dependency> <4>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
</dependency>
----
<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 the dependency to `spring-cloud-starter-sleuth` - that way all dependant dependencies will be downloaded
<4> Add a binder (e.g. Rabbit binder) to tell Spring Cloud Stream what it should bind to
<2> Add the dependency to `spring-cloud-starter-sleuth-zipkin2` - that way all dependent dependencies will be downloaded
<3> To automatically configure rabbit, simply add the spring-rabbit dependency

[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"]
.Gradle
Expand All @@ -434,29 +372,19 @@ dependencyManagement { <1>
}
dependencies {
compile "org.springframework.cloud:spring-cloud-sleuth-zipkin-stream" <2>
compile "org.springframework.cloud:spring-cloud-starter-sleuth" <3>
// Example for Rabbit binding
compile "org.springframework.cloud:spring-cloud-stream-binder-rabbit" <4>
compile "org.springframework.cloud:spring-cloud-starter-sleuth-zipkin2" <2>
compile "org.springframework.amqp:spring-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 the dependency to `spring-cloud-starter-sleuth` - that way all dependant dependencies will be downloaded
<4> 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[]
----
<2> Add the dependency to `spring-cloud-starter-sleuth-zipkin2` - that way all dependent dependencies will be downloaded
<3> To automatically configure rabbit, simply add the spring-rabbit dependency

== Additional resources

*Marcin Grzejszczak talking about Spring Cloud Sleuth and Zipkin*

video::eQV71Mw1u1c[youtube]

https://www.youtube.com/watch?v=eQV71Mw1u1c[click here to see the video]
https://www.youtube.com/watch?v=eQV71Mw1u1c[click here to see the video]
21 changes: 2 additions & 19 deletions spring-cloud-sleuth-samples/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ There are a few samples with slightly different features. You can run all of the

* `spring-cloud-sleuth-sample`: vanilla (no zipkin) web app that calls back to itself on various endpoints ("/", "/call", "/async")

* `spring-cloud-sleuth-sample-zipkin`: same as vanilla sample but with zipkin (set `sample.zipkin.enabled=true` if you have a collector running)

* `spring-cloud-sleuth-sample-stream`: same as vanilla sample, but exports span data to RabbitMQ using Spring Cloud Stream

* `spring-cloud-sleuth-sample-stream-zipkin`: a consumer for the span data on RabbitMQ that pushes it into a Zipkin span store, so it can be queried and visualized using the embedded Zipkin UI.
* `spring-cloud-sleuth-sample-zipkin2`: same as vanilla sample but with zipkin (set `sample.zipkin.enabled=true` if you have a collector running)

* `spring-cloud-sleuth-sample-messaging`: a Spring Integration application with two HTTP endpoints ("/" and "/xform")

Expand All @@ -20,7 +16,7 @@ The Ribbon sample makes an interesting demo or playground for learning about zip

=== Running samples with Zipkin

1. Optionally run the https://github.com/openzipkin/zipkin[Zipkin] Server, e.g. via docker compose (there's a `docker-compose.yml` in https://github.com/spring-cloud/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin[Spring Cloud Sleuth], or in https://github.com/openzipkin/docker-zipkin[Docker Zipkin]
1. Optionally run the https://github.com/openzipkin/zipkin[Zipkin] Server, e.g. via docker compose (there's a `docker-compose.yml` in https://github.com/spring-cloud/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin2[Spring Cloud Sleuth], or in https://github.com/openzipkin/docker-zipkin[Docker Zipkin]
7. Run the zipkin sample application (set `sample.zipkin.enabled=false` if you have no Zipkin running). If you are using a VM to run docker you might need to tunnel port 9411 to localhost, or change the `spring.zipkin.baseUrl`.
8. Hit `http://localhost:3380`, `http://localhost:3380/call`, `http://localhost:3380/async` for some interesting sample traces (the app callas back to itself).
9. Go to `http://localhost:9411` for Zipkin's UI (if you are using boot2docker the host will be different)
Expand All @@ -30,16 +26,3 @@ NOTE: You can see the zipkin spans without the UI (in logs) if you run the sampl
image::{github-raw}/docs/src/main/asciidoc/images/zipkin-trace-screenshot.png[Sample Zipkin Screenshot]

> The fact that the first trace in says "testSleuthMessaging" seems to be a bug in the UI (it has some annotations from that service, but it originates in the "testSleuthRibbon" service).

=== Running samples with Zipkin Stream

Instead of POSTing trace data directly to a Zipkin server, you can export them over https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream[Spring Cloud Stream].

1. Run the RabbitMQ middleware for Zipkin (you can use `docker-compose.yml`).
2. Build the Zipkin Stream sample with Maven and run it.
7. Run the `spring-cloud-sleuth-sample-stream` app and interact with it in a browser, just like the vanilla sample. If you are using a VM to run docker you might need to tunnel port 5672 to localhost, or change the `spring.rabbbitmq.host`.
9. Go to `http://localhost:9411` for Zipkin's UI

The UI should look more or less like this:

image::{github-raw}/docs/src/main/asciidoc/images/zipkin-traces.png[Zipkin Web Screenshot]
2 changes: 0 additions & 2 deletions spring-cloud-sleuth-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
<module>spring-cloud-sleuth-sample-feign</module>
<module>spring-cloud-sleuth-sample-ribbon</module>
<module>spring-cloud-sleuth-sample-zipkin2</module>
<module>spring-cloud-sleuth-sample-stream</module>
<module>spring-cloud-sleuth-sample-zipkin-stream</module>
</modules>

<build>
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 808572d

Please sign in to comment.