diff --git a/spring-cloud-sleuth.html b/spring-cloud-sleuth.html index 5b0b922d2..84555c20b 100644 --- a/spring-cloud-sleuth.html +++ b/spring-cloud-sleuth.html @@ -489,6 +489,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
  • Spring Integration
  • HTTP
  • Example
  • +
  • TraceFilter
  • Custom SA tag in Zipkin
  • Custom service name
  • Customization of reported spans
  • @@ -2340,6 +2341,38 @@ HttpResponseInjectingTraceFilter responseInjectingTraceFilter(Tracer tracer) {
    +

    TraceFilter

    +
    +

    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.

    +
    +
    +
    +
    @Bean
    +TraceFilter myTraceFilter(BeanFactory beanFactory, final Tracer tracer) {
    +	return new TraceFilter(beanFactory) {
    +		@Override protected void addResponseTags(HttpServletResponse response,
    +				Throwable e) {
    +			// execute the default behaviour
    +			super.addResponseTags(response, e);
    +			// for readability we're returning trace id in a hex form
    +			response.addHeader("ZIPKIN-TRACE-ID",
    +					Span.idToHex(tracer.getCurrentSpan().getTraceId()));
    +			// we can also add some custom tags
    +			tracer.addTag("custom", "tag");
    +		}
    +	};
    +}
    +
    +
    +
    +

    Custom SA tag in Zipkin

    Sometimes you want to create a manual Span that will wrap a call to an external service which is not instrumented.