@@ -771,7 +771,7 @@ setting proper tags on the span which Zipkin can properly colorize. You could se
diff --git a/spring-cloud-sleuth.html b/spring-cloud-sleuth.html index e4b6f3ccd..e89f7c371 100644 --- a/spring-cloud-sleuth.html +++ b/spring-cloud-sleuth.html @@ -562,7 +562,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
Spring Cloud Sleuth borrows Dapper’s terminology.
In the following sections the example from the image above will be taken into consideration.
Altogether there are 7 spans . If you go to traces in Zipkin you will see this number in the second trace:
service1 and 3 spans related to RPC calls.
Zipkin allows you to visualize errors in your trace. When an exception was thrown and wasn’t caught then we’re setting proper tags on the span which Zipkin can properly colorize. You could see in the list of traces one @@ -748,7 +748,7 @@ setting proper tags on the span which Zipkin can properly colorize. You could se
When grepping the logs of those four applications by trace id equal to e.g. 2485ec27856c56f4 one would get the following:
Often you do not want to store your logs in a text file but in a JSON file that Logstash can immediately pick. To do that you have to do the following (for readability
we’re passing the dependencies in the groupId:artifactId:version notation.
logback-spring.xml then you have to
The span context is the state that must get propagated to any child Spans across process boundaries. Part of the Span Context is the Baggage. The trace and span IDs are a required part of the span context. @@ -1001,7 +1001,7 @@ initialSpan.setBaggageItem("UPPER_CASE", "someValue");
Baggage travels with the trace (i.e. every child span contains the baggage of its parent). Zipkin has no knowledge of baggage and will not even receive that information.
@@ -1028,9 +1028,9 @@ tracer.addTag(baggageKey, baggageValue);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.
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-sleuth-stream dependency.
If you want to start a Spring Cloud Sleuth Stream Zipkin collector just add the spring-cloud-sleuth-zipkin-stream
dependency
Marcin Grzejszczak talking about Spring Cloud Sleuth and Zipkin
@@ -1371,7 +1371,7 @@ public class ZipkinStreamServerApplication {In distributed tracing the data volumes can be very high so sampling @@ -1556,7 +1556,7 @@ regardless of the sampling decision.
Spring Cloud Sleuth instruments all your Spring application @@ -1606,7 +1606,7 @@ This approach may change in the future towards being lazy on this matter.
You can do the following operations on the Span by means of org.springframework.cloud.sleuth.Tracer interface:
@@ -1646,7 +1646,7 @@ Spring creates the instance ofTracer for you. In order to use it a
You can manually create spans by using the Tracer interface.
Sometimes you don’t want to create a new span but you want to continue one. Example of such a situation might be (of course it all depends on the use-case):
@@ -1765,7 +1765,7 @@ Always clean after you create a span! Don’t forget to detach a span if somThere is a possibility that you want to start a new span and provide an explicit parent of that span. Let’s assume that the parent of a span is in one thread and you want to start a new span in another thread. The @@ -1810,7 +1810,7 @@ After having created such a span remember to close it. Otherwise you will see a
Picking a span name is not a trivial task. Span name should depict an operation name. The name should @@ -1837,7 +1837,7 @@ artificial like:
Fortunately, for the asynchronous processing you can provide explicit naming.
You can name the span explicitly via the @SpanName annotation.
It’s pretty rare to create separate classes for Runnable or Callable. Typically one creates an anonymous
instance of those classes. You can’t annotate such classes thus to override that, if there is no @SpanName annotation present,
@@ -1900,10 +1900,10 @@ future.get();
The main arguments for this features are
If you really don’t want to take care of creating local spans manually you can profit from the
@NewSpan annotation. Also we give you the @SpanTag annotation to add tags in an automated
@@ -2007,7 +2007,7 @@ concrete one wins (in this case customNameOnTestMethod3 will be set
If you want to just add tags and annotations to an existing span it’s enough
to use the @ContinueSpan annotation as presented below. Note that in contrast
@@ -2041,7 +2041,7 @@ this.testBean.testMethod11("test");
There are 3 different ways to add tags to a span. All of them are controlled by the SpanTag annotation.
Precedence is:
The value of the tag for following method will be computed by an implementation of TagValueResolver interface.
Its class name has to be passed as the value of the resolver attribute.
Having such an annotated method:
Having such an annotated method:
Thanks to the SpanInjector and SpanExtractor you can customize the way spans
@@ -2164,7 +2164,7 @@ implementation of a SpanTextMap that delegates calls to FooR
and insertion of HTTP headers.
For Spring Integration there are 2 interfaces responsible for creation of a Span from a Message.
These are:
For HTTP there are 2 interfaces responsible for creation of a Span from a Message.
These are:
Let’s assume that instead of the standard Zipkin compatible tracing HTTP header names you have
@@ -2339,7 +2339,7 @@ HttpResponseInjectingTraceFilter responseInjectingTraceFilter(Tracer tracer) {Sometimes you want to create a manual Span that will wrap a call to an external service which is not instrumented.
What you can do is to create a span with the peer.service tag that will contain a value of the service that you want to call.
@@ -2377,7 +2377,7 @@ Remember not to add both peer.service tag and the SA t
By default Sleuth assumes that when you send a span to Zipkin, you want the span’s service name
to be equal to spring.application.name value. That’s not always the case though. There
@@ -2392,7 +2392,7 @@ Remember not to add both peer.service tag and the SA t
Before reporting spans to e.g. Zipkin you can be interested in modifying that span in some way.
You can achieve that by using the SpanAdjuster interface.
SpanReporter should inject the SpanAdjuster and
In order to define the host that is corresponding to a particular span we need to resolve the host name and port. The default approach is to take it from server properties. If those for some reason are not set @@ -2450,7 +2450,7 @@ Stream based span reporting).
By default if you add spring-cloud-starter-zipkin as a dependency to your project,
@@ -2475,7 +2475,7 @@ Zipkin’s service id inside the URL (example for zipkinserver
You can accumulate and send span data over
@@ -2488,7 +2488,7 @@ automatically turn your app into a producer of messages with payload
type Spans.
There is a special convenience annotation for setting up a message consumer
for the Span data and pushing it into a Zipkin SpanStore. This application
A custom consumer can also easily be implemented using
spring-cloud-sleuth-stream and binding to the SleuthSink. Example:
Currently Spring Cloud Sleuth registers very simple metrics related to spans. @@ -2633,10 +2633,10 @@ the number of dropped spans will get increased.
If you’re wrapping your logic in Runnable or Callable it’s enough to wrap those classes in their Sleuth representative.
We’re registering a custom HystrixConcurrencyStrategy
that wraps all Callable instances into their Sleuth representative -
@@ -2702,7 +2702,7 @@ on before the Hystrix command was called. To disable the custom Hystrix Concurre
Assuming that you have the following HystrixCommand:
We’re registering a custom RxJavaSchedulersHook
that wraps all Action0 instances into their Sleuth representative -
@@ -2746,12 +2746,12 @@ of regular expressions in the spring.sleuth.rxjava.schedulers.ignoredthrea
Features from this section can be disabled by providing the spring.sleuth.web.enabled property with value equal to false.
Via the TraceFilter all sampled incoming requests result in creation of a Span. That Span’s name is http: + the path to which
the request was sent. E.g. if the request was sent to /foo/bar then the name will be http:/foo/bar. You can configure which URIs you would
@@ -2760,7 +2760,7 @@ of regular expressions in the spring.sleuth.rxjava.schedulers.ignoredthrea
Since we want the span names to be precise we’re using a TraceHandlerInterceptor that either wraps an
existing HandlerInterceptor or is added directly to the list of existing HandlerInterceptors. The
@@ -2771,16 +2771,16 @@ of regular expressions in the spring.sleuth.rxjava.schedulers.ignoredthrea
If your controller returns a Callable or a WebAsyncTask Spring Cloud Sleuth will continue the existing span instead of creating a new one.
We’re injecting a RestTemplate interceptor that ensures that all the tracing information is passed to the requests. Each time a
call is made a new Span is created. It gets closed upon receiving the response. In order to block the synchronous RestTemplate features
@@ -2801,7 +2801,7 @@ If you create a RestTemplate instance with a new keywo