Jonathan Chevalier
Jonathan Chevalier

Reputation: 1218

Micrometer tracing context propagration is lost in webclient flatMap function

Project: https://github.com/Jojoooo1/spring-microservice-webhook-reactive

Version:

Even after using Hooks.enableAutomaticContextPropagation() it seems that nested context does not propagate. It was previously working using sleuth.

First context:

enter image description here

Second context enter image description here

Does anyone had similar issue and was able to fix it ?

Upvotes: 1

Views: 2902

Answers (3)

Jonathan Chevalier
Jonathan Chevalier

Reputation: 1218

https://github.com/spring-projects/spring-amqp/issues/2560 has solved the problem.

The context is being lost between webclient and rabbit listener you need to add .tap(Micrometer.observation(this.registry)):

return this.webClient
        .post()
        .uri(url)
        .contentType(MediaType.APPLICATION_JSON)
        .headers(
            httpHeaders ->
                headers.forEach((k, v) -> httpHeaders.add(k, v != null ? v.toString() : null)))
        .bodyValue(requestBody)
        .exchangeToMono(this::defaultResponseHandler)
        .tap(Micrometer.observation(this.registry))

Upvotes: 0

kar66
kar66

Reputation: 9

According to Automatic Context Propagation since version 3.5.3 of reactor-core following line should be added in one place inside the application :

    Hooks.enableAutomaticContextPropagation();

Upvotes: -1

Trind
Trind

Reputation: 1599

I upgraded to 'io.projectreactor:reactor-core:3.6.0' and I got it to work.

Upvotes: -1

Related Questions