3

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();
Rayyan
  • 107
  • 12

1 Answers1

1

This should be fixed fixed in Sleuth 3.1.3

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32
  • Thanks for the update. Do we have Sleuth in Spring Boot 3.x ? I was with the understanding that we need to move to Micrometer. – Rayyan Jan 02 '23 at 17:37
  • There's no Sleuth compatible version for Spring Boot 3. The problem is not present in Spring Boot 3 because we don't automatically instrument Reactor so that it injects trace identifiers in thread locals. – Marcin Grzejszczak Jan 05 '23 at 08:58