question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

traceId / spanId generated are changed post WebClient call

See original GitHub issue

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 we 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();

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
MohithMarisetticommented, May 5, 2022

I’m having an almost similar issue with Spring cloud sleuth 3.x.x. I recently upgraded to Spring boot 2.6.6 and Sleuth 3.x.x. After the upgrade I see my HandlerInterceptor class is giving a different traceId in the afterCompletion() method. More info available here

@marcingrzejszczak @syedyusufh Any solution for this problem?

0reactions
marcingrzejszczakcommented, May 24, 2022

From what I see in this sample https://github.com/syedyusufh/sleuth-web-webflux.git it has nothing to do with WebClient. It’s more with the fact that the TraceValve didn’t properly support async dispatch. That means calling TraceValve twice with an span attribute already set once would not reuse span but create the new one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

traceId / spanId generated are changed post WebClient call
The traceId / spanId generated are getting changed post the WebClient call. Spring Boot v2.6.1 and Spring Cloud v3.1.0.
Read more >
Spring Boot and Tracing Calls - The Blog of Ivan Krizsan
The trace id from the request to the circle resource is preserved but a new span id is generated for the request to...
Read more >
Tracing messages in Choreography with Sleuth and Zipkin
It runs from request to response. These traceId and spanId propagate through REST calls automatically. You really don't need to do anything ...
Read more >
Spring Cloud Sleuth Features
Distributed tracing works by propagating fields inside and across services that connect the trace together: traceId and spanId notably.
Read more >
Spring Cloud Sleuth | Auto Configuration for Distributed Tracing
Sleuth is nothing but the tool which was provided by spring cloud, used to generate service calls, the diagnostic context of mapping and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found