\ No newline at end of file
diff --git a/multi/multi__current_span.html b/multi/multi__current_span.html
index 6df2346f9..20f4099c3 100644
--- a/multi/multi__current_span.html
+++ b/multi/multi__current_span.html
@@ -1,6 +1,6 @@
- 7. Current Span
Brave supports a "current span" concept which represents the in-flight operation.
You can use Tracer.currentSpan() to add custom tags to a span and Tracer.nextSpan() to create a child of whatever is in-flight.
Important
In Sleuth, you can autowire the Tracer bean to retrieve the current span via
tracer.currentSpan() method. To retrieve the current context just call
tracer.currentSpan().context(). To get the current trace id as String
diff --git a/multi/multi__current_tracing_component.html b/multi/multi__current_tracing_component.html
index 75511b6ac..99f56c3cd 100644
--- a/multi/multi__current_tracing_component.html
+++ b/multi/multi__current_tracing_component.html
@@ -1,6 +1,6 @@
Brave supports a "current tracing component" concept, which should only be used when you have no other way to get a reference.
This was made for JDBC connections, as they often initialize prior to the tracing component.
The most recent tracing component instantiated is available through Tracing.current().
You can also use Tracing.currentTracer() to get only the tracer.
If you use either of these methods, do not cache the result.
diff --git a/multi/multi__customizations.html b/multi/multi__customizations.html
index 4b3d74485..6c076f043 100644
--- a/multi/multi__customizations.html
+++ b/multi/multi__customizations.html
@@ -1,6 +1,6 @@
If a customization of client / server parsing of the HTTP related spans is required,
just register a bean of type brave.http.HttpClientParser or
brave.http.HttpServerParser. If client /server sampling is required, just
register a bean of type brave.http.HttpSampler and name the bean
@@ -27,7 +27,7 @@ an example of usage of SkipPatternProvider inside a
}
};
}
-}
12.2 TracingFilter
You can also modify the behavior of the TracingFilter, which is the component that is responsible for processing the input HTTP request and adding tags basing on the HTTP response.
+}
12.2 TracingFilter
You can also modify the behavior of the TracingFilter, which is the component that is responsible for processing the input HTTP request and adding tags basing on the HTTP response.
You can customize the tags or modify the response headers by registering your own instance of the TracingFilter bean.
In the following example, we register the TracingFilter bean, add the ZIPKIN-TRACE-ID response header containing the current Span’s trace id, and add a tag with key custom and a value tag to the span.
@Component@Order(TraceWebServletAutoConfiguration.TRACING_FILTER_ORDER + 1)class MyFilter extends GenericFilterBean {
@@ -53,7 +53,8 @@ You can customize the tags or modify the response headers by registering your ow
currentSpan.tag("custom", "tag");
chain.doFilter(request, response);
}
-}
12.3 Custom service name
By default, Sleuth assumes that, when you send a span to Zipkin, you want the span’s service name to be equal to the value of the spring.application.name property.
+}
+//end::response_headers[]
12.3 Custom service name
By default, Sleuth assumes that, when you send a span to Zipkin, you want the span’s service name to be equal to the value of the spring.application.name property.
That is not always the case, though.
There are situations in which you want to explicitly provide a different service name for all spans coming from your application.
To achieve that, you can pass the following property to your application to override that value (the example is for a service named myService):
spring.zipkin.service.name: myService
12.4 Customization of Reported Spans
Before reporting spans (for example, to Zipkin) you may want to modify that span in some way.
diff --git a/multi/multi__features.html b/multi/multi__features.html
index ec8619c5c..58c7029fa 100644
--- a/multi/multi__features.html
+++ b/multi/multi__features.html
@@ -1,6 +1,6 @@
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, as shown in the following example logs:
2016-02-02 15:30:57.902 INFO [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23030 --- [nio-8081-exec-3] ...
+ 3. 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, as shown in the following example logs:
Notice the [appname,traceId,spanId,exportable] entries from the MDC:
spanId: The ID of a specific operation that took place.
appname: The name of the application that logged the span.
traceId: The ID of the latency graph that contains the span.
exportable: Whether the log should be exported to Zipkin.
When would you like the span not to be exportable?
diff --git a/multi/multi__instrumentation.html b/multi/multi__instrumentation.html
index 82c1d45de..519547517 100644
--- a/multi/multi__instrumentation.html
+++ b/multi/multi__instrumentation.html
@@ -1,6 +1,6 @@
- 8. Instrumentation
Spring Cloud Sleuth automatically instruments all your Spring applications, so you should not have to do anything to activate it.
The instrumentation is added by using a variety of technologies according to the stack that is available. For example, for a servlet web application, we use a Filter, and, for Spring Integration, we use ChannelInterceptors.
You can customize the keys used in span tags.
To limit the volume of span data, an HTTP request is, by default, tagged only with a handful of metadata, such as the status code, the host, and the URL.
You can add request headers by configuring spring.sleuth.keys.http.headers (a list of header names).
Note
Tags are collected and exported only if there is a Sampler that allows it. By default, there is no such Sampler, to ensure that there is no danger of accidentally collecting too much data without configuring something).
\ No newline at end of file
diff --git a/multi/multi__integrations.html b/multi/multi__integrations.html
index 92ab2269c..03b3f2c12 100644
--- a/multi/multi__integrations.html
+++ b/multi/multi__integrations.html
@@ -1,6 +1,6 @@
- 15. Integrations
Spring Cloud Sleuth is compatible with OpenTracing.
If you have OpenTracing on the classpath, we automatically register the OpenTracing Tracer bean.
If you wish to disable this, set spring.sleuth.opentracing.enabled to false
15.2 Runnable and Callable
If you wrap your logic in Runnable or Callable, you can wrap those classes in their Sleuth representative, as shown in the following example for Runnable:
Runnable runnable = new Runnable() {
@Override
@@ -104,22 +104,22 @@ In the following snippet, you can see an example of how to set up such a custom
//CUSTOMIZE HEREreturn factory;
}
-}
15.6.3 WebClient
We inject a ExchangeFilterFunction implementation that creates a span and, through on-success and on-error callbacks, takes care of closing client-side spans.
To block this feature, set spring.sleuth.web.client.enabled to false.
Important
You have to register WebClient as a bean so that the tracing instrumentation gets applied.
+}
15.6.3 WebClient
We inject a ExchangeFilterFunction implementation that creates a span and, through on-success and on-error callbacks, takes care of closing client-side spans.
To block this feature, set spring.sleuth.web.client.enabled to false.
Important
You have to register WebClient as a bean so that the tracing instrumentation gets applied.
If you create a WebClient instance with a new keyword, the instrumentation does NOT work.
15.6.4 Traverson
If you use the Traverson library, you can inject a RestTemplate as a bean into your Traverson object.
Since RestTemplate is already intercepted, you get full support for tracing in your client. The following pseudo code
shows 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.5 Apache HttpClientBuilder and HttpAsyncClientBuilder
We instrument the HttpClientBuilder and HttpAsyncClientBuilder so that
-tracing context gets injected to the sent requests.
To block these features, set spring.sleuth.web.client.enabled to false.
15.6.6 Netty HttpClient
We instrument the Netty’s HttpClient.
To block this feature, set spring.sleuth.web.client.enabled to false.
Important
You have to register HttpClient as a bean so that the instrumentation happens.
-If you create a HttpClient instance with a new keyword, the instrumentation does NOT work.
15.6.7 UserInfoRestTemplateCustomizer
We instrument the Spring Security’s UserInfoRestTemplateCustomizer.
To block this feature, set spring.sleuth.web.client.enabled to false.
15.7 Feign
By default, Spring Cloud Sleuth provides integration with Feign through TraceFeignClientAutoConfiguration.
+// use Traverson
15.6.5 Apache HttpClientBuilder and HttpAsyncClientBuilder
We instrument the HttpClientBuilder and HttpAsyncClientBuilder so that
+tracing context gets injected to the sent requests.
To block these features, set spring.sleuth.web.client.enabled to false.
15.6.6 Netty HttpClient
We instrument the Netty’s HttpClient.
To block this feature, set spring.sleuth.web.client.enabled to false.
Important
You have to register HttpClient as a bean so that the instrumentation happens.
+If you create a HttpClient instance with a new keyword, the instrumentation does NOT work.
15.6.7 UserInfoRestTemplateCustomizer
We instrument the Spring Security’s UserInfoRestTemplateCustomizer.
To block this feature, set spring.sleuth.web.client.enabled to false.
15.7 Feign
By default, Spring Cloud Sleuth provides integration with Feign through TraceFeignClientAutoConfiguration.
You can disable it entirely by setting spring.sleuth.feign.enabled to false.
If you do so, no Feign-related instrumentation take place.
Part of Feign instrumentation is done through a FeignBeanPostProcessor.
You can disable it by setting spring.sleuth.feign.processor.enabled to false.
If you set it to false, Spring Cloud Sleuth does not instrument any of your custom Feign components.
-However, all the default instrumentation is still there.
15.8 Asynchronous Communication
15.8.1 @Async Annotated methods
In Spring Cloud Sleuth, we instrument async-related components so that the tracing information is passed between threads.
-You can disable this behavior by setting the value of spring.sleuth.async.enabled to false.
If you annotate your method with @Async, we automatically create a new Span with the following characteristics:
If the method is annotated with @SpanName, the value of the annotation is the Span’s name.
If the method is not annotated with @SpanName, the Span name is the annotated method name.
The span is tagged with the method’s class name and method name.
15.8.2 @Scheduled Annotated Methods
In Spring Cloud Sleuth, we instrument scheduled method execution so that the tracing information is passed between threads.
+However, all the default instrumentation is still there.
15.8 Asynchronous Communication
15.8.1 @Async Annotated methods
In Spring Cloud Sleuth, we instrument async-related components so that the tracing information is passed between threads.
+You can disable this behavior by setting the value of spring.sleuth.async.enabled to false.
If you annotate your method with @Async, we automatically create a new Span with the following characteristics:
If the method is annotated with @SpanName, the value of the annotation is the Span’s name.
If the method is not annotated with @SpanName, the Span name is the annotated method name.
The span is tagged with the method’s class name and method name.
15.8.2 @Scheduled Annotated Methods
In Spring Cloud Sleuth, we instrument scheduled method execution so that the tracing information is passed between threads.
You can disable this behavior by setting the value of spring.sleuth.scheduled.enabled to false.
If you annotate your method with @Scheduled, we automatically create a new span with the following characteristics:
The span name is the annotated method name.
The span is tagged with the method’s class name and method name.
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 matches the fully qualified name of the @Scheduled annotated class.
If you use spring-cloud-sleuth-stream and spring-cloud-netflix-hystrix-stream together, a span is created for each Hystrix metrics and sent to Zipkin.
This behavior may be annoying. That’s why, by default, spring.sleuth.scheduled.skipPattern=org.springframework.cloud.netflix.hystrix.stream.HystrixStreamTask.
15.8.3 Executor, ExecutorService, and ScheduledExecutorService
We provide LazyTraceExecutor, TraceableExecutorService, and TraceableScheduledExecutorService. Those implementations create spans each time a new task is submitted, invoked, or scheduled.
The following example shows how to pass tracing information with TraceableExecutorService when working with CompletableFuture:
Span: The basic unit of work. For example, sending an RPC is a new span, as is sending a response to an RPC.
Spans are identified by a unique 64-bit ID for the span and another 64-bit ID for the trace the span is a part of.
Spans also have other data, such as descriptions, timestamped events, key-value annotations (tags), the ID of the span that caused them, and process IDs (normally IP addresses).
Spans can be started and stopped, and they keep track of their timing information.
Once you create a span, you must stop it at some point in the future.
Tip
The initial span that starts a trace is called a root span. The value of the ID
diff --git a/multi/multi__managing_spans_with_annotations.html b/multi/multi__managing_spans_with_annotations.html
index 2b8601f0a..ffce8c7e5 100644
--- a/multi/multi__managing_spans_with_annotations.html
+++ b/multi/multi__managing_spans_with_annotations.html
@@ -1,6 +1,6 @@
You can manage spans with a variety of annotations.
11.1 Rationale
There are a number of good reasons to manage spans with annotations, including:
API-agnostic means to collaborate with a span. Use of annotations lets users add to a span with no library dependency on a span api.
+ 11. Managing Spans with Annotations
You can manage spans with a variety of annotations.
11.1 Rationale
There are a number of good reasons to manage spans with annotations, including:
API-agnostic means to collaborate with a span. Use of annotations lets users add to a span with no library dependency on a span api.
Doing so lets Sleuth change its core API to create less impact to user code.
Reduced surface area for basic span operations. Without this feature, you must use the span api, which has lifecycle commands that could be used incorrectly.
By only exposing scope, tag, and log functionality, you can collaborate without accidentally breaking span lifecycle.
Collaboration with runtime generated code. With libraries such as Spring Data and Feign, the implementations of interfaces are generated at runtime.
Consequently, span wrapping of objects was tedious.
@@ -38,6 +38,6 @@ Its class name has to be passed as the value of the resolv
}
The two preceding examples lead to setting a tag value equal to Value from myCustomTagValueResolver.
No custom implementation of a TagValueExpressionResolver leads to evaluation of the SPEL expression, and a tag with a value of 4 characters is set on the span.
-If you want to use some other expression resolution mechanism, you can create your own implementation of the bean.
11.4.3 Using the toString() method
Consider the following annotated method:
@NewSpan
+If you want to use some other expression resolution mechanism, you can create your own implementation of the bean.
11.4.3 Using the toString() method
Consider the following annotated method:
@NewSpanpublicvoid getAnnotationForArgumentToString(@SpanTag("test") Long param) {
}
Running the preceding method with a value of 15 leads to setting a tag with a String value of "15".
\ No newline at end of file
diff --git a/multi/multi__naming_spans.html b/multi/multi__naming_spans.html
index abfa42cf2..7ba3a9dfd 100644
--- a/multi/multi__naming_spans.html
+++ b/multi/multi__naming_spans.html
@@ -1,7 +1,7 @@
- 10. Naming spans
Picking a span name is not a trivial task. A span name should depict an operation name.
-The name should be low cardinality, so it should not include identifiers.
Since there is a lot of instrumentation going on, some span names are artificial:
controller-method-name when received by a Controller with a method name of controllerMethodName
async for asynchronous operations done with wrapped Callable and Runnable interfaces.
Methods annotated with @Scheduled return the simple name of the class.
Fortunately, for asynchronous processing, you can provide explicit naming.
10.1 @SpanName Annotation
You can name the span explicitly by using the @SpanName annotation, as shown in the following example:
Picking a span name is not a trivial task. A span name should depict an operation name.
+The name should be low cardinality, so it should not include identifiers.
Since there is a lot of instrumentation going on, some span names are artificial:
controller-method-name when received by a Controller with a method name of controllerMethodName
async for asynchronous operations done with wrapped Callable and Runnable interfaces.
Methods annotated with @Scheduled return the simple name of the class.
Fortunately, for asynchronous processing, you can provide explicit naming.
10.1 @SpanName Annotation
You can name the span explicitly by using the @SpanName annotation, as shown in the following example:
@SpanName("calculateTax")class TaxCountingRunnable implements Runnable {
@Overridepublicvoid run() {
@@ -11,7 +11,7 @@ The name should be low cardinality, so it should not include identifiers.
new TaxCountingRunnable());
Future<?> future = executorService.submit(runnable);
// ... some additional logic ...
-future.get();
10.2 toString() method
It is pretty rare to create separate classes for Runnable or Callable.
+future.get();
10.2 toString() method
It is pretty rare to create separate classes for Runnable or Callable.
Typically, one creates an anonymous instance of those classes.
You cannot annotate such classes.
To overcome that limitation, if there is no @SpanName annotation present, we check whether the class has a custom implementation of the toString() method.
Running such code leads to creating a span named calculateTax, as shown in the following example:
Runnable runnable = new TraceRunnable(tracing, spanNamer, new Runnable() {
diff --git a/multi/multi__propagation.html b/multi/multi__propagation.html
index bbf57d5c3..58648a9d5 100644
--- a/multi/multi__propagation.html
+++ b/multi/multi__propagation.html
@@ -1,6 +1,6 @@
- 5. Propagation
Propagation is needed to ensure activities originating from the same root are collected together in the same trace.
The most common propagation approach is to copy a trace context from a client by sending an RPC request to a server receiving it.
For example, when a downstream HTTP call is made, its trace context is encoded as request headers and sent along with it, as shown in the following image:
Zipkin for Brewery on PWS, its Github Code.
Ensure that you’ve picked the lookback period of 7 days. If there are no traces, go to Presenting application
diff --git a/multi/multi__sampling.html b/multi/multi__sampling.html
index 31d88638c..94f3a51bf 100644
--- a/multi/multi__sampling.html
+++ b/multi/multi__sampling.html
@@ -1,6 +1,6 @@
- 4. Sampling
Sampling may be employed to reduce the data collected and reported out of process.
When a span is not sampled, it adds no overhead (a noop).
Sampling is an up-front decision, meaning that the decision to report data is made at the first operation in a trace and that decision is propagated downstream.
By default, a global sampler applies a single rate to all traced operations.
Tracer.Builder.sampler controls this setting, and it defaults to tracing every request.
4.1 Declarative sampling
Some applications need to sample based on the type or annotations of a java method.
Most users use a framework interceptor to automate this sort of policy.
The following example shows how that might work internally:
By default, if you add spring-cloud-starter-zipkin as a dependency to your project, when the span is closed, it is sent to Zipkin over HTTP.
The communication is asynchronous.
You can configure the URL by setting the spring.zipkin.baseUrl property, as follows:
If you want to find Zipkin through service discovery, you can pass the Zipkin’s service ID inside the URL, as shown in the following example for zipkinserver service ID:
spring.zipkin.baseUrl: http://zipkinserver/
To disable this feature just set spring.zipkin.discoveryClientEnabled to `false.
When the Discovery Client feature is enabled, Sleuth uses
LoadBalancerClient to find the URL of the Zipkin Server. It means
diff --git a/multi/multi__span_lifecycle.html b/multi/multi__span_lifecycle.html
index f68933a72..66dc72b91 100644
--- a/multi/multi__span_lifecycle.html
+++ b/multi/multi__span_lifecycle.html
@@ -1,6 +1,6 @@
You can do the following operations on the Span by means of brave.Tracer:
start: When you start a span, its name is assigned and the start timestamp is recorded.
close: The span gets finished (the end time of the span is recorded) and, if the span is sampled, it is eligible for collection (for example, to Zipkin).
continue: A new instance of span is created.
+ 9. Span lifecycle
You can do the following operations on the Span by means of brave.Tracer:
start: When you start a span, its name is assigned and the start timestamp is recorded.
close: The span gets finished (the end time of the span is recorded) and, if the span is sampled, it is eligible for collection (for example, to Zipkin).
continue: A new instance of span is created.
It is a copy of the one that it continues.
detach: The span does not get stopped or closed.
It only gets removed from the current thread.
Spring Cloud Sleuth creates an instance of Tracer for you. In order to use it, you can autowire it.
9.1 Creating and finishing spans
You can manually create spans by using the Tracer, as shown in the following example:
// Start a span. If there was a span present in this thread it will become// the `newSpan`'s parent.
diff --git a/multi/multi__zipkin_stream_span_consumer.html b/multi/multi__zipkin_stream_span_consumer.html
index 6570accf0..6ed1bda61 100644
--- a/multi/multi__zipkin_stream_span_consumer.html
+++ b/multi/multi__zipkin_stream_span_consumer.html
@@ -1,5 +1,5 @@
- 14. Zipkin Stream Span Consumer
We recommend using Zipkin’s native support for message-based span sending.
Starting from the Edgware release, the Zipkin Stream server is deprecated.
In the Finchley release, it got removed.
If for some reason you need to create the deprecated Stream Zipkin server, see the Dalston Documentation.
\ No newline at end of file
diff --git a/multi/multi_pr01.html b/multi/multi_pr01.html
index e151ea40e..d980e1748 100644
--- a/multi/multi_pr01.html
+++ b/multi/multi_pr01.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
diff --git a/multi/multi_spring-cloud-sleuth.html b/multi/multi_spring-cloud-sleuth.html
index 4e22be643..f6f005dc0 100644
--- a/multi/multi_spring-cloud-sleuth.html
+++ b/multi/multi_spring-cloud-sleuth.html
@@ -1,3 +1,3 @@
- Spring Cloud Sleuth
\ No newline at end of file
diff --git a/single/spring-cloud-sleuth.html b/single/spring-cloud-sleuth.html
index be9331267..f7eb90302 100644
--- a/single/spring-cloud-sleuth.html
+++ b/single/spring-cloud-sleuth.html
@@ -1,6 +1,6 @@
- Spring Cloud Sleuth
Spring Cloud Sleuth
Adrian Cole, Spencer Gibb, Marcin Grzejszczak, Dave Syer, Jay Bryant
Span: The basic unit of work. For example, sending an RPC is a new span, as is sending a response to an RPC.
Spans are identified by a unique 64-bit ID for the span and another 64-bit ID for the trace the span is a part of.
Spans also have other data, such as descriptions, timestamped events, key-value annotations (tags), the ID of the span that caused them, and process IDs (normally IP addresses).
Spans can be started and stopped, and they keep track of their timing information.
Once you create a span, you must stop it at some point in the future.
Tip
The initial span that starts a trace is called a root span. The value of the ID
@@ -602,7 +602,7 @@ Span newSpan = null;
newSpan.finish();
}
}
Important
After creating such a span, you must finish it. Otherwise it is not reported (for example, to Zipkin).
10. Naming spans
Picking a span name is not a trivial task. A span name should depict an operation name.
-The name should be low cardinality, so it should not include identifiers.
Since there is a lot of instrumentation going on, some span names are artificial:
controller-method-name when received by a Controller with a method name of controllerMethodName
async for asynchronous operations done with wrapped Callable and Runnable interfaces.
Methods annotated with @Scheduled return the simple name of the class.
Fortunately, for asynchronous processing, you can provide explicit naming.
10.1 @SpanName Annotation
You can name the span explicitly by using the @SpanName annotation, as shown in the following example:
@SpanName("calculateTax")
+The name should be low cardinality, so it should not include identifiers.
Since there is a lot of instrumentation going on, some span names are artificial:
controller-method-name when received by a Controller with a method name of controllerMethodName
async for asynchronous operations done with wrapped Callable and Runnable interfaces.
Methods annotated with @Scheduled return the simple name of the class.
Fortunately, for asynchronous processing, you can provide explicit naming.
10.1 @SpanName Annotation
You can name the span explicitly by using the @SpanName annotation, as shown in the following example:
@SpanName("calculateTax")class TaxCountingRunnable implements Runnable {
@Overridepublicvoid run() {
@@ -612,7 +612,7 @@ The name should be low cardinality, so it should not include identifiers.
new TaxCountingRunnable());
Future<?> future = executorService.submit(runnable);
// ... some additional logic ...
-future.get();
10.2 toString() method
It is pretty rare to create separate classes for Runnable or Callable.
+future.get();
10.2 toString() method
It is pretty rare to create separate classes for Runnable or Callable.
Typically, one creates an anonymous instance of those classes.
You cannot annotate such classes.
To overcome that limitation, if there is no @SpanName annotation present, we check whether the class has a custom implementation of the toString() method.
Running such code leads to creating a span named calculateTax, as shown in the following example:
Runnable runnable = new TraceRunnable(tracing, spanNamer, new Runnable() {
@@ -664,7 +664,7 @@ Its class name has to be passed as the value of the resolv
}
The two preceding examples lead to setting a tag value equal to Value from myCustomTagValueResolver.
No custom implementation of a TagValueExpressionResolver leads to evaluation of the SPEL expression, and a tag with a value of 4 characters is set on the span.
-If you want to use some other expression resolution mechanism, you can create your own implementation of the bean.
11.4.3 Using the toString() method
Consider the following annotated method:
@NewSpan
+If you want to use some other expression resolution mechanism, you can create your own implementation of the bean.
11.4.3 Using the toString() method
Consider the following annotated method:
@NewSpanpublicvoid getAnnotationForArgumentToString(@SpanTag("test") Long param) {
}
Running the preceding method with a value of 15 leads to setting a tag with a String value of "15".
12. Customizations
12.1 HTTP
If a customization of client / server parsing of the HTTP related spans is required,
just register a bean of type brave.http.HttpClientParser or
@@ -693,7 +693,7 @@ an example of usage of SkipPatternProvider inside a
}
};
}
-}
12.2 TracingFilter
You can also modify the behavior of the TracingFilter, which is the component that is responsible for processing the input HTTP request and adding tags basing on the HTTP response.
+}
12.2 TracingFilter
You can also modify the behavior of the TracingFilter, which is the component that is responsible for processing the input HTTP request and adding tags basing on the HTTP response.
You can customize the tags or modify the response headers by registering your own instance of the TracingFilter bean.
In the following example, we register the TracingFilter bean, add the ZIPKIN-TRACE-ID response header containing the current Span’s trace id, and add a tag with key custom and a value tag to the span.
@Component@Order(TraceWebServletAutoConfiguration.TRACING_FILTER_ORDER + 1)class MyFilter extends GenericFilterBean {
@@ -719,7 +719,8 @@ You can customize the tags or modify the response headers by registering your ow
currentSpan.tag("custom", "tag");
chain.doFilter(request, response);
}
-}
12.3 Custom service name
By default, Sleuth assumes that, when you send a span to Zipkin, you want the span’s service name to be equal to the value of the spring.application.name property.
+}
+//end::response_headers[]
12.3 Custom service name
By default, Sleuth assumes that, when you send a span to Zipkin, you want the span’s service name to be equal to the value of the spring.application.name property.
That is not always the case, though.
There are situations in which you want to explicitly provide a different service name for all spans coming from your application.
To achieve that, you can pass the following property to your application to override that value (the example is for a service named myService):
spring.zipkin.service.name: myService
12.4 Customization of Reported Spans
Before reporting spans (for example, to Zipkin) you may want to modify that span in some way.
@@ -875,22 +876,22 @@ In the following snippet, you can see an example of how to set up such a custom
//CUSTOMIZE HEREreturn factory;
}
-}
15.6.3 WebClient
We inject a ExchangeFilterFunction implementation that creates a span and, through on-success and on-error callbacks, takes care of closing client-side spans.
To block this feature, set spring.sleuth.web.client.enabled to false.
Important
You have to register WebClient as a bean so that the tracing instrumentation gets applied.
+}
15.6.3 WebClient
We inject a ExchangeFilterFunction implementation that creates a span and, through on-success and on-error callbacks, takes care of closing client-side spans.
To block this feature, set spring.sleuth.web.client.enabled to false.
Important
You have to register WebClient as a bean so that the tracing instrumentation gets applied.
If you create a WebClient instance with a new keyword, the instrumentation does NOT work.
15.6.4 Traverson
If you use the Traverson library, you can inject a RestTemplate as a bean into your Traverson object.
Since RestTemplate is already intercepted, you get full support for tracing in your client. The following pseudo code
shows 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.5 Apache HttpClientBuilder and HttpAsyncClientBuilder
We instrument the HttpClientBuilder and HttpAsyncClientBuilder so that
-tracing context gets injected to the sent requests.
To block these features, set spring.sleuth.web.client.enabled to false.
15.6.6 Netty HttpClient
We instrument the Netty’s HttpClient.
To block this feature, set spring.sleuth.web.client.enabled to false.
Important
You have to register HttpClient as a bean so that the instrumentation happens.
-If you create a HttpClient instance with a new keyword, the instrumentation does NOT work.
15.6.7 UserInfoRestTemplateCustomizer
We instrument the Spring Security’s UserInfoRestTemplateCustomizer.
To block this feature, set spring.sleuth.web.client.enabled to false.
15.7 Feign
By default, Spring Cloud Sleuth provides integration with Feign through TraceFeignClientAutoConfiguration.
+// use Traverson
15.6.5 Apache HttpClientBuilder and HttpAsyncClientBuilder
We instrument the HttpClientBuilder and HttpAsyncClientBuilder so that
+tracing context gets injected to the sent requests.
To block these features, set spring.sleuth.web.client.enabled to false.
15.6.6 Netty HttpClient
We instrument the Netty’s HttpClient.
To block this feature, set spring.sleuth.web.client.enabled to false.
Important
You have to register HttpClient as a bean so that the instrumentation happens.
+If you create a HttpClient instance with a new keyword, the instrumentation does NOT work.
15.6.7 UserInfoRestTemplateCustomizer
We instrument the Spring Security’s UserInfoRestTemplateCustomizer.
To block this feature, set spring.sleuth.web.client.enabled to false.
15.7 Feign
By default, Spring Cloud Sleuth provides integration with Feign through TraceFeignClientAutoConfiguration.
You can disable it entirely by setting spring.sleuth.feign.enabled to false.
If you do so, no Feign-related instrumentation take place.
Part of Feign instrumentation is done through a FeignBeanPostProcessor.
You can disable it by setting spring.sleuth.feign.processor.enabled to false.
If you set it to false, Spring Cloud Sleuth does not instrument any of your custom Feign components.
-However, all the default instrumentation is still there.
15.8 Asynchronous Communication
15.8.1 @Async Annotated methods
In Spring Cloud Sleuth, we instrument async-related components so that the tracing information is passed between threads.
-You can disable this behavior by setting the value of spring.sleuth.async.enabled to false.
If you annotate your method with @Async, we automatically create a new Span with the following characteristics:
If the method is annotated with @SpanName, the value of the annotation is the Span’s name.
If the method is not annotated with @SpanName, the Span name is the annotated method name.
The span is tagged with the method’s class name and method name.
15.8.2 @Scheduled Annotated Methods
In Spring Cloud Sleuth, we instrument scheduled method execution so that the tracing information is passed between threads.
+However, all the default instrumentation is still there.
15.8 Asynchronous Communication
15.8.1 @Async Annotated methods
In Spring Cloud Sleuth, we instrument async-related components so that the tracing information is passed between threads.
+You can disable this behavior by setting the value of spring.sleuth.async.enabled to false.
If you annotate your method with @Async, we automatically create a new Span with the following characteristics:
If the method is annotated with @SpanName, the value of the annotation is the Span’s name.
If the method is not annotated with @SpanName, the Span name is the annotated method name.
The span is tagged with the method’s class name and method name.
15.8.2 @Scheduled Annotated Methods
In Spring Cloud Sleuth, we instrument scheduled method execution so that the tracing information is passed between threads.
You can disable this behavior by setting the value of spring.sleuth.scheduled.enabled to false.
If you annotate your method with @Scheduled, we automatically create a new span with the following characteristics:
The span name is the annotated method name.
The span is tagged with the method’s class name and method name.
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 matches the fully qualified name of the @Scheduled annotated class.
If you use spring-cloud-sleuth-stream and spring-cloud-netflix-hystrix-stream together, a span is created for each Hystrix metrics and sent to Zipkin.
This behavior may be annoying. That’s why, by default, spring.sleuth.scheduled.skipPattern=org.springframework.cloud.netflix.hystrix.stream.HystrixStreamTask.
15.8.3 Executor, ExecutorService, and ScheduledExecutorService
We provide LazyTraceExecutor, TraceableExecutorService, and TraceableScheduledExecutorService. Those implementations create spans each time a new task is submitted, invoked, or scheduled.
The following example shows how to pass tracing information with TraceableExecutorService when working with CompletableFuture: