diff --git a/multi/multi__features.html b/multi/multi__features.html
index 878b49fb5..30821373f 100644
--- a/multi/multi__features.html
+++ b/multi/multi__features.html
@@ -10,9 +10,9 @@ latency in your applications. Sleuth is written to not log too much, and to not
rest template, scheduled actions, message channels, zuul filters, feign client).
Sleuth includes default logic to join a trace across http or messaging boundaries. For example, http propagation
works via Zipkin-compatible request headers. This propagation logic is defined and customized via
SpanInjector and SpanExtractor implementations.
Sleuth gives you the possibility to propagate context (also known as baggage) between processes. That means that if you set on a Span
-a baggage element then it will be sent downstream either via HTTP or messaging to other processes.
Provides a way to create / continue spans and add tags and logs via annotations.
Provides simple metrics of accepted / dropped spans.
If spring-cloud-sleuth-zipkin then the app will generate and collect Zipkin-compatible traces.
+a baggage element then it will be sent downstream either via HTTP or messaging to other processes.
Provides a way to create / continue spans and add tags and logs via annotations.
If spring-cloud-sleuth-zipkin 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.
Important
If using Zipkin, configure the percentage of spans exported using spring.sleuth.sampler.percentage
+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 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:-}]
diff --git a/multi/multi__integrations.html b/multi/multi__integrations.html
index 14f982f14..b95972eed 100644
--- a/multi/multi__integrations.html
+++ b/multi/multi__integrations.html
@@ -1,6 +1,8 @@
Spring Cloud Sleuth is OpenTracing compatible. If you have
+OpenTracing on the classpath we will automatically register the OpenTracing
+Tracer bean. If you wish to disable this just set spring.sleuth.opentracing.enabled to false
15.2 Runnable and Callable
If you’re wrapping your logic in Runnable or Callable it’s enough to wrap those classes in their Sleuth representative.
Example for Runnable:
Runnable runnable = new Runnable() {
@Overridepublicvoid run() {
// do some work
@@ -32,10 +34,10 @@ Callable<String> traceCallable = "calculateTax");
// Wrapping `Callable` with `Tracing`. That way the current span will be available// in the thread of `Callable`
-Callable<String> traceCallableFromTracer = tracing.currentTraceContext().wrap(callable);
That way you will ensure that a new Span is created and closed for each execution.
15.2 Hystrix
15.2.1 Custom Concurrency Strategy
We’re registering a custom HystrixConcurrencyStrategy
+Callable<String> traceCallableFromTracer = tracing.currentTraceContext().wrap(callable);
That way you will ensure that a new Span is created and closed for each execution.
15.3 Hystrix
15.3.1 Custom Concurrency Strategy
We’re registering a custom HystrixConcurrencyStrategy
that wraps all Callable instances into their Sleuth representative -
the TraceCallable. The strategy either starts or continues a span depending on the fact whether tracing was already going
-on before the Hystrix command was called. To disable the custom Hystrix Concurrency Strategy set the spring.sleuth.hystrix.strategy.enabled to false.
15.2.2 Manual Command setting
Assuming that you have the following HystrixCommand:
HystrixCommand<String> hystrixCommand = new HystrixCommand<String>(setter) {
+on before the Hystrix command was called. To disable the custom Hystrix Concurrency Strategy set the spring.sleuth.hystrix.strategy.enabled to false.
15.3.2 Manual Command setting
Assuming that you have the following HystrixCommand:
HystrixCommand<String> hystrixCommand = new HystrixCommand<String>(setter) {
@Overrideprotected String run() throws Exception {
return someLogic();
@@ -46,25 +48,25 @@ on before the Hystrix command was called. To disable the custom Hystrix Concurre
public String doRun() throws Exception {
return someLogic();
}
-};
We’re registering a custom RxJavaSchedulersHook
that wraps all Action0 instances into their Sleuth representative -
the TraceAction. The hook either starts or continues a span depending on the fact whether tracing was already going
on before the Action was scheduled. To disable the custom RxJavaSchedulersHook set the spring.sleuth.rxjava.schedulers.hook.enabled to false.
You can define a list of regular expressions for thread names, for which you don’t want a Span to be created. Just provide a comma separated list
-of regular expressions in the spring.sleuth.rxjava.schedulers.ignoredthreads property.
15.4 HTTP integration
Features from this section can be disabled by providing the spring.sleuth.web.enabled property with value equal to false.
15.4.1 HTTP Filter
Via the TraceFilter all sampled incoming requests result in creation of a Span. That Span’s name is http: + the path to which
+of regular expressions in the spring.sleuth.rxjava.schedulers.ignoredthreads property.
15.5 HTTP integration
Features from this section can be disabled by providing the spring.sleuth.web.enabled property with value equal to false.
15.5.1 HTTP Filter
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
like to skip via the spring.sleuth.web.skipPattern property. If you have ManagementServerProperties on classpath then
- its value of contextPath gets appended to the provided skip pattern.
15.4.2 HandlerInterceptor
Since we want the span names to be precise we’re using a TraceHandlerInterceptor that either wraps an
+ its value of contextPath gets appended to the provided skip pattern.
15.5.2 HandlerInterceptor
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
TraceHandlerInterceptor adds a special request attribute to the given HttpServletRequest. If the
the TraceFilter doesn’t see this attribute set it will create a "fallback" span which is an additional
span created on the server side so that the trace is presented properly in the UI. Seeing that most likely
- signifies that there is a missing instrumentation. In that case please file an issue in Spring Cloud Sleuth.
15.4.3 Async Servlet support
If your controller returns a Callable or a WebAsyncTask Spring Cloud Sleuth will continue the existing span instead of creating a new one.
15.4.4 WebFlux support
Via the TraceWebFilter all sampled incoming requests result in creation of a Span. That Span’s name is http: + the path to which
+ signifies that there is a missing instrumentation. In that case please file an issue in Spring Cloud Sleuth.
15.5.3 Async Servlet support
If your controller returns a Callable or a WebAsyncTask Spring Cloud Sleuth will continue the existing span instead of creating a new one.
15.5.4 WebFlux support
Via the TraceWebFilter 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
like to skip via the spring.sleuth.web.skipPattern property. If you have ManagementServerProperties on classpath then
- its value of contextPath gets appended to the provided skip pattern.
15.5 HTTP client integration
15.5.1 Synchronous Rest Template
We’re injecting a RestTemplate interceptor that ensures that all the tracing information is passed to the requests. Each time a
+ its value of contextPath gets appended to the provided skip pattern.
15.6 HTTP client integration
15.6.1 Synchronous Rest Template
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
just set spring.sleuth.web.client.enabled to false.
Important
You have to register RestTemplate as a bean so that the interceptors will get injected.
-If you create a RestTemplate instance with a new keyword then the instrumentation WILL NOT work.
15.5.2 Asynchronous Rest Template
Important
Starting with Sleuth 2.0.0 we no longer register
+If you create a RestTemplate instance with a new keyword then the instrumentation WILL NOT work.
15.6.2 Asynchronous Rest Template
Important
Starting with Sleuth 2.0.0 we no longer register
a bean of AsyncRestTemplate type. It’s up to you to create such
a bean. Then we will instrument it.
To block the AsyncRestTemplate features set spring.sleuth.web.async.client.enabled to false.
To disable creation of the default TraceAsyncClientHttpRequestFactoryWrapper set spring.sleuth.web.async.client.factory.enabled
@@ -89,23 +91,23 @@ can see an example of how to set up such a custom AsyncRes
//CUSTOMIZE HEREreturn factory;
}
-}
15.5.3 WebClient
We inject a ExchangeFilterFunction implementation that creates a span and via on success and on
+}
15.6.3 WebClient
We inject a ExchangeFilterFunction implementation that creates a span and via on success and on
error callbacks takes care of closing client side spans.
Important
You have to register WebClient as a bean so that the tracing instrumention gets applied.
-If you create a WebClient instance with a new keyword then the instrumentation WILL NOT work.
15.5.4 Traverson
If you’re using the Traverson library
+If you create a WebClient instance with a new keyword then the instrumentation WILL NOT work.
15.6.4 Traverson
If you’re using the Traverson library
it’s enough for you to inject a RestTemplate as a bean into your Traverson object. Since RestTemplate
is already intercepted, you will get full support of tracing in your client. Below you can find a pseudo code
of how to do that:
@Autowired RestTemplate restTemplate;
Traverson traverson = new Traverson(URI.create("http://some/address"),
MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_UTF8).setRestOperations(restTemplate);
-// use Traverson
15.6 Feign
By default Spring Cloud Sleuth provides integration with feign via the TraceFeignClientAutoConfiguration. You can disable it entirely
+// use Traverson
15.7 Feign
By default Spring Cloud Sleuth provides integration with feign via the TraceFeignClientAutoConfiguration. You can disable it entirely
by setting spring.sleuth.feign.enabled to false. If you do so then no Feign related instrumentation will take place.
Part of Feign instrumentation is done via a FeignBeanPostProcessor. You can disable it by providing the spring.sleuth.feign.processor.enabled equal to false.
If you set it like this then Spring Cloud Sleuth will not instrument any of your custom Feign components. All the default instrumentation
-however will be still there.
15.7 Asynchronous communication
15.7.1 @Async annotated methods
In Spring Cloud Sleuth we’re instrumenting async related components so that the tracing information is passed between threads.
-You can disable this behaviour by setting the value of spring.sleuth.async.enabled to false.
If you annotate your method with @Async then we’ll automatically create a new Span with the following characteristics:
if the method is annotated with @SpanName then the value of the annotation will be the Span’s name
if the method is not annotated with @SpanName the Span name will be the annotated method name
the Span will be tagged with that method’s class name and the method name too
15.7.2 @Scheduled annotated methods
In Spring Cloud Sleuth we’re instrumenting scheduled method execution so that the tracing information is passed between threads. You can disable this behaviour
+however will be still there.
15.8 Asynchronous communication
15.8.1 @Async annotated methods
In Spring Cloud Sleuth we’re instrumenting async related components so that the tracing information is passed between threads.
+You can disable this behaviour by setting the value of spring.sleuth.async.enabled to false.
If you annotate your method with @Async then we’ll automatically create a new Span with the following characteristics:
if the method is annotated with @SpanName then the value of the annotation will be the Span’s name
if the method is not annotated with @SpanName the Span name will be the annotated method name
the Span will be tagged with that method’s class name and the method name too
15.8.2 @Scheduled annotated methods
In Spring Cloud Sleuth we’re instrumenting scheduled method execution so that the tracing information is passed between threads. You can disable this behaviour
by setting the value of spring.sleuth.scheduled.enabled to false.
If you annotate your method with @Scheduled then we’ll automatically create a new Span with the following characteristics:
the Span name will be the annotated method name
the Span will be tagged with that method’s class name and the method name too
If you want to skip Span creation for some @Scheduled annotated classes you can set the
spring.sleuth.scheduled.skipPattern with a regular expression that will match the fully qualified name of the
-@Scheduled annotated class.
Tip
If you are using spring-cloud-sleuth-stream and spring-cloud-netflix-hystrix-stream together, Span will be created for each Hystrix metrics and sent to Zipkin. This may be annoying. You can prevent this by setting spring.sleuth.scheduled.skipPattern=org.springframework.cloud.netflix.hystrix.stream.HystrixStreamTask
15.7.3 Executor, ExecutorService and ScheduledExecutorService
We’re providing LazyTraceExecutor, TraceableExecutorService and TraceableScheduledExecutorService. Those implementations
+@Scheduled annotated class.
Tip
If you are using spring-cloud-sleuth-stream and spring-cloud-netflix-hystrix-stream together, Span will be created for each Hystrix metrics and sent to Zipkin. This may be annoying. You can prevent this by setting spring.sleuth.scheduled.skipPattern=org.springframework.cloud.netflix.hystrix.stream.HystrixStreamTask
15.8.3 Executor, ExecutorService and ScheduledExecutorService
We’re providing LazyTraceExecutor, TraceableExecutorService and TraceableScheduledExecutorService. Those implementations
are creating Spans each time a new task is submitted, invoked or scheduled.
Here you can see an example of how to pass tracing information with TraceableExecutorService when working with CompletableFuture:
CompletableFuture<Long> completableFuture = CompletableFuture.supplyAsync(() -> {
// perform some logicreturn1_000_000L;
@@ -132,9 +134,9 @@ can see an example of how to set up such a custom Executor
executor.initialize();
returnnew LazyTraceExecutor(this.beanFactory, executor);
}
-}
15.8 Messaging
Spring Cloud Sleuth integrates with Spring Integration. It creates spans for publish and
+}
15.9 Messaging
Spring Cloud Sleuth integrates with Spring Integration. It creates spans for publish and
subscribe events. To disable Spring Integration instrumentation, set spring.sleuth.integration.enabled to false.
You can provide the spring.sleuth.integration.patterns pattern to explicitly
provide the names of channels that you want to include for tracing. By default all channels
are included.
Important
When using the Executor to build a Spring Integration IntegrationFlow remember to use the untraced version of the Executor.
-Decorating Spring Integration Executor Channel with TraceableExecutorService will cause the spans to be improperly closed.
15.9 Zuul
We’re registering Zuul filters to propagate the tracing information (the request header is enriched with tracing data).
+Decorating Spring Integration Executor Channel with TraceableExecutorService will cause the spans to be improperly closed.
15.10 Zuul
We’re registering Zuul filters to propagate the tracing information (the request header is enriched with tracing data).
To disable Zuul support set the spring.sleuth.zuul.enabled property to false.
\ No newline at end of file
diff --git a/multi/multi_spring-cloud-sleuth.html b/multi/multi_spring-cloud-sleuth.html
index f5a19ea28..b6f14c4ee 100644
--- a/multi/multi_spring-cloud-sleuth.html
+++ b/multi/multi_spring-cloud-sleuth.html
@@ -1,3 +1,3 @@
- Spring Cloud Sleuth