diff --git a/multi/multi__customizations.html b/multi/multi__customizations.html index 0a34819f6..43676f077 100644 --- a/multi/multi__customizations.html +++ b/multi/multi__customizations.html @@ -1,10 +1,7 @@
-You can also modify the behaviour of the TraceFilter - 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 TraceFilter bean.
In the following example we will register the TraceFilter bean and we will add the
-ZIPKIN-TRACE-ID response header containing the current Span’s trace id. Also we will
-add to the Span a tag with key custom and a value tag.
@Component +12. Customizations \ No newline at end of file +}You can also modify the behavior of the
TraceFilter, 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 theTraceFilterbean.In the following example, we register the
TraceFilterbean, add theZIPKIN-TRACE-IDresponse header containing the current Span’s trace id, and add a tag with keycustomand a valuetagto the span.@Component @Order(TraceFilter.ORDER + 1) class MyFilter extends GenericFilterBean { @@ -26,21 +23,19 @@ add to the Span a tag with keycustomand a value < currentSpan.tag("custom", "tag"); chain.doFilter(request, response); } -}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.namevalue. That’s 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 it’s enough to just pass the following property - to your application to override that value (example forfooservice name):spring.zipkin.service.name: fooBefore reporting spans to e.g. Zipkin you can be interested in modifying that span in some way. - You can achieve that by using the
SpanAdjusterinterface.In Sleuth we’re generating spans with a fixed name. Some users want to modify the name depending on values -of tags. Implementation of the
SpanAdjusterinterface can be used to alter that name. Example:Example. If you register two beans of
SpanAdjustertype:@Bean SpanAdjuster adjusterOne() { +}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.nameproperty. +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 namedmyService):spring.zipkin.service.name: myServiceBefore reporting spans (for example, to Zipkin) you may want to modify that span in some way. +You can do so by using the
SpanAdjusterinterface.In Sleuth, we generat spans with a fixed name. +Some users want to modify the name depending on values of tags. +You can implement the
SpanAdjusterinterface to alter that name.The following example shows how to register two beans that implement
SpanAdjuster:@Bean SpanAdjuster adjusterOne() { return span -> span.toBuilder().name("foo").build(); } @Bean SpanAdjuster adjusterTwo() { return span -> span.toBuilder().name(span.name() + " bar").build(); -}This will lead in changing the name of the reported span to
foo bar, just before it gets reported (e.g. to Zipkin).
Important This section is about defining host from service discovery. It’s NOT -about finding Zipkin in service discovery.
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 -then we’re trying to retrieve the host name from the network interfaces.
If you have the discovery client enabled and prefer to retrieve the host address from the registered -instance in a service registry then you have to set the property (it’s applicable for both HTTP and -Stream based span reporting).
spring.zipkin.locator.discovery.enabled: true
The preceding example results in changing the name of the reported span to foo bar, just before it gets reported (for example, to Zipkin).
![]() | Important |
|---|---|
This section is about defining host from service discovery. +It is NOT about finding Zipkin through service discovery. |
To define the host that corresponds to a particular span, we need to resolve the host name and port. +The default approach is to take these values from server properties. +If those are not set, we try to retrieve the host name from the network interfaces.
If you have the discovery client enabled and prefer to retrieve the host address from the registered instance in a service registry, you have to set the spring.zipkin.locator.discovery.enabled property (it is applicable for both HTTP-based and Stream-based span reporting), as follows:
spring.zipkin.locator.discovery.enabled: true