This repository contains a demo that demonstrates various less known features of Spring Cloud Sleuth.
This demo repository is part of a bigger demo system. To get started just initialize the submodules.
$ git submodules init
$ git submodules updateNow you can start the whole system (ELK, 4 demo apps, Zipkin) by running
$ pushd vagrant-elk-box
$ ./getReadyForConference.sh
$ popd vagrant-elk-boxNow, wait for some time for the Vagrant box to start, demo apps to start, Zipkin to start and some requests get sent.
You’re ready to run this application. Just start it and curl
$ curl --header "X-B3-Flags:1" localhost:8765/s1por using httpie
$ http localhost:8765/s1p X-B3-Flags:1-
Creating spans via annotations
-
especially useful for interfaces (e.g. Spring Data)
-
-
Baggage
-
Sleuth specific (via baggage_ header prefix)
-
-
Span adjusters
-
list of custom adjusters of spans before reporting
-
-
RestTemplateBuilder support
-
the built RestTemplate is tracing aware
-
-
Zipkin load balanced/discovery using Eureka
-
pass the service id in the URL
-
-
Reactor Support
-
tracing context passed through Flux
-
-
Zipkin2 Support
-
starter-zipkinnow points to Zipkin2
-
-
Deprecation of Stream server
-
migrate to Zipkin2 with rabbit
-
-
WebFlux & WebClient support
-
tracing context passed through the Flux
-
WebClient is tracing aware
-
-
Removal of Stream server
-
you should use Zipkin 2 native messaging support
-
migrate by having both the old Stream server and the new Zipkin 2 store spans to the same storage
-
start migrating apps from Sleuth Stream client to Zipkin 2
-
-
Removal of OAuth2 support
-
will be removed once it’s re-added in Security
-
-
Create a project from start.spring.io (Reactive Web, Zipkin, Lombok)
-
Assuming that the
vagrant-elk-boxgets updated to Edgware for the samples, need to update zipkin dependency to zipkin2 (assuming that I don’t update initlizr)[Edgware] -
Write a
s1pControllerreturningMono<String>[Finchley] -
Create a
MyServiceclass that will callservice1viaWebClient[Finchley] -
Add the
WebClient.Builderbean - explain thatRestTemplate/RestTemplateBuildercan be used[Finchley / Edgware] -
Set
spring.application.nameandspring.sleuth.sampler.percentage=1.0in properties -
Run the app and see if things pop up in Zipkin
-
Set baggage
baggage→s1pin controller and run again - show how baggage gets picked in service1[Dalston] -
Create 2 methods in
MyService, one@NewSpan(“surprise”)the other@ContinueSpan(log = “very_important_method”), both with `@SpanTagmethod params. Methods should sleep and log some stuff out.[Dalston] -
Run again, show new spans. Show the baggage logs, show the annotation logs
-
Say that you don’t like the span names. You’d like the span that has
http.pathto have a changed name. Create aSpanAdjusterBean that will checkhttp.pathtag to contain one with path/s1pand change its name tohacked!. Rerun the application[Dalston] -
Change sampler percentage to
0.0and show that spans are not sampled. Now callhttp localhost:8080/s1p X-B3-Flags:1and show that the debug mode works fine - the span is sampled[Dalston] -
Create a
Fooclass withUuidfield, change@TagValueto contain a resolver on one of the methods. Create a beanTagValueResolver myCustomTagValueResolverthat will return foo’s uuid or any object’s to string[Dalston] -
Show how you could find Zipkin from Service Discovery
spring.zipkin.baseUrl: http://zipkinserver/[Edgware] -
Add the
@EnableAsyncand@Asyncmethod on theMyService. Add the@SpanNameon the method and add some logging. Until Edgware the method’s name was the span name - now it has changed[Edgware] -
Calling an external, unmanaged service. In
MyServiceadd thecallPivotalmethod. Create a span manually [Dalston] Showing how to call a peer service. Create aRestTemplateBuilderbean[Edgware], that will point tohttps://pivotal.io. Build theRestTemplatein MyService constructor. New method inMyServicewith@NewSpan. Add a taglc⇒Pivotal. SetCSbefore the calltry {} finally {}overRestTemplatecall. Infinallysetpeer.servicetopivotal,peer.ipv4e.g.InetAddress.getByName("pivotal.io").getHostAddress() `, `"peer.port", "80". Finally log eventCR. Re-run and show the new pivotal service[Dalston]