Search code examples
spring-cloud-sleuthreactor-netty

traceId / spanId generated are changed post WebClient call


We are using ReactorNettyHttpTracing with our Spring Web + Spring WebFlux + Spring Cloud Sleuth application. The traceId / spanId generated are getting changed post the WebClient call.

Spring Boot v2.6.1 and Spring Cloud v3.1.0

How do I retain the same traceId and spanId for the entire Spring Web request?

    @Bean
    public ReactorNettyHttpTracing reactorNettyHttpTracing(HttpTracing httpTracing) {
        return ReactorNettyHttpTracing.create(httpTracing);
    }

    WebClient.builder()
            .clientConnector(new ReactorClientHttpConnector(tracing.decorateHttpClient(httpClient)))
            .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
            .filters(exchangeFilters -> { 
                exchangeFilters.add(exchangeFilter.logRequest());
                exchangeFilters.add(exchangeFilter.logResponse());
            }).build();

Solution

  • This should be fixed fixed in Sleuth 3.1.3