Source:
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws IOException, ServletException { final Map<String, String> requestHeaders = Collections.list(request.getHeaderNames()) .stream() .collect(Collectors.toMap(h -> h, request::getHeader)); final SpanContext spanContext = GlobalTracer.get() .extract(HTTP_HEADERS, new TextMapExtractAdapter(requestHeaders)); final Span publishingSpan; final long startTime = System.currentTimeMillis(); if (spanContext != null) { publishingSpan = TracingService.getNewSpan("publish_events", startTime, spanContext); } else { publishingSpan = TracingService.getNewSpan("publish_events", startTime); } try { final RequestLogInfo requestLogInfo = new RequestLogInfo(request, startTime); if (isPublishingRequest(requestLogInfo)) { final Scope scope = TracingService.activateSpan(publishingSpan, false); TracingService.setCustomTags(scope, ImmutableMap.<String, Object>builder() .put("client_id", requestLogInfo.user) .put("http.url", requestLogInfo.path + requestLogInfo.query) .put("http.header.content_encoding", requestLogInfo.contentEncoding) .put("http.header.accept_encoding", requestLogInfo.acceptEncoding) .put("http.header.user_agent", requestLogInfo.userAgent) .build()); request.setAttribute("span", publishingSpan); } filterChain.doFilter(request, response); if (request.isAsyncStarted()) { final String flowId = FlowIdUtils.peek(); request.getAsyncContext().addListener(new AsyncRequestListener(request, response, startTime, flowId, publishingSpan)); } } finally { if (!request.isAsyncStarted()) { final RequestLogInfo requestLogInfo = new RequestLogInfo(request, startTime); logRequest(requestLogInfo, response.getStatus(), publishingSpan); } final Map<String, String> spanContextToInject = new HashMap<>(); GlobalTracer.get().inject(publishingSpan.context(), HTTP_HEADERS, new TextMapInjectAdapter(spanContextToInject)); response.setHeader("span_ctx",spanContextToInject.toString()); publishingSpan.finish(); } }

Target:
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws IOException, ServletException { final Map<String, String> requestHeaders = Collections.list(request.getHeaderNames()) .stream() .collect(Collectors.toMap(h -> h, request::getHeader)); final SpanContext spanContext = GlobalTracer.get() .extract(HTTP_HEADERS, new TextMapExtractAdapter(requestHeaders)); final Span publishingSpan; final long startTime = System.currentTimeMillis(); if (spanContext != null) { publishingSpan = TracingService.getNewSpan("publish_events", startTime, spanContext); } else { publishingSpan = TracingService.getNewSpan("publish_events", startTime); } try { final RequestLogInfo requestLogInfo = new RequestLogInfo(request, startTime); if (isPublishingRequest(requestLogInfo)) { final Scope scope = TracingService.activateSpan(publishingSpan, false); TracingService.setCustomTags(scope, ImmutableMap.<String, Object>builder() .put("client_id", requestLogInfo.user) .put("http.url", requestLogInfo.path + requestLogInfo.query) .put("http.header.content_encoding", requestLogInfo.contentEncoding) .put("http.header.accept_encoding", requestLogInfo.acceptEncoding) .put("http.header.user_agent", requestLogInfo.userAgent) .build()); request.setAttribute("span", publishingSpan); } filterChain.doFilter(request, response); if (request.isAsyncStarted()) { final String flowId = FlowIdUtils.peek(); request.getAsyncContext().addListener(new AsyncRequestListener(request, response, startTime, flowId, publishingSpan)); } } finally { if (!request.isAsyncStarted()) { final RequestLogInfo requestLogInfo = new RequestLogInfo(request, startTime); logRequest(requestLogInfo, response.getStatus(), publishingSpan); } final Map<String, String> spanContextToInject = new HashMap<>(); GlobalTracer.get().inject(publishingSpan.context(), HTTP_HEADERS, new TextMapInjectAdapter(spanContextToInject)); response.setHeader(SPAN_CONTEXT, spanContextToInject.toString()); publishingSpan.finish(); } }