diff --git a/multi/multi__customizations.html b/multi/multi__customizations.html index 43676f077..a963a5af7 100644 --- a/multi/multi__customizations.html +++ b/multi/multi__customizations.html @@ -2,7 +2,7 @@ 12. Customizations

12. Customizations

12.1 TraceFilter

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 the TraceFilter bean.

In the following example, we register the TraceFilter 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(TraceFilter.ORDER + 1)
+@Order(TraceWebServletAutoConfiguration.TRACING_FILTER_ORDER + 1)
 class MyFilter extends GenericFilterBean {
 
 	private final Tracer tracer;
@@ -14,7 +14,9 @@ You can customize the tags or modify the response headers by registering your ow
 	@Override public void doFilter(ServletRequest request, ServletResponse response,
 			FilterChain chain) throws IOException, ServletException {
 		Span currentSpan = this.tracer.currentSpan();
-		then(currentSpan).isNotNull();
+		if (currentSpan == null) {
+			return;
+		}
 		// for readability we're returning trace id in a hex form
 		((HttpServletResponse) response)
 				.addHeader("ZIPKIN-TRACE-ID",
diff --git a/single/spring-cloud-sleuth.html b/single/spring-cloud-sleuth.html
index e45b55ee7..807435497 100644
--- a/single/spring-cloud-sleuth.html
+++ b/single/spring-cloud-sleuth.html
@@ -597,7 +597,7 @@ If you want to use some other expression resolution mechanism, you can create yo
 public void 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 TraceFilter

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 the TraceFilter bean.

In the following example, we register the TraceFilter 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(TraceFilter.ORDER + 1)
+@Order(TraceWebServletAutoConfiguration.TRACING_FILTER_ORDER + 1)
 class MyFilter extends GenericFilterBean {
 
 	private final Tracer tracer;
@@ -609,7 +609,9 @@ You can customize the tags or modify the response headers by registering your ow
 	@Override public void doFilter(ServletRequest request, ServletResponse response,
 			FilterChain chain) throws IOException, ServletException {
 		Span currentSpan = this.tracer.currentSpan();
-		then(currentSpan).isNotNull();
+		if (currentSpan == null) {
+			return;
+		}
 		// for readability we're returning trace id in a hex form
 		((HttpServletResponse) response)
 				.addHeader("ZIPKIN-TRACE-ID",
diff --git a/spring-cloud-sleuth.xml b/spring-cloud-sleuth.xml
index 491bf904e..99a43aed9 100644
--- a/spring-cloud-sleuth.xml
+++ b/spring-cloud-sleuth.xml
@@ -1386,7 +1386,7 @@ public void getAnnotationForArgumentToString(@SpanTag("test") Long param) {
 You can customize the tags or modify the response headers by registering your own instance of the TraceFilter bean.
 In the following example, we register the TraceFilter 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(TraceFilter.ORDER + 1)
+@Order(TraceWebServletAutoConfiguration.TRACING_FILTER_ORDER + 1)
 class MyFilter extends GenericFilterBean {
 
 	private final Tracer tracer;
@@ -1398,7 +1398,9 @@ class MyFilter extends GenericFilterBean {
 	@Override public void doFilter(ServletRequest request, ServletResponse response,
 			FilterChain chain) throws IOException, ServletException {
 		Span currentSpan = this.tracer.currentSpan();
-		then(currentSpan).isNotNull();
+		if (currentSpan == null) {
+			return;
+		}
 		// for readability we're returning trace id in a hex form
 		((HttpServletResponse) response)
 				.addHeader("ZIPKIN-TRACE-ID",