Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Micrometer tracing context propagration is lost in webclient flatMap function

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

Version:

  • spring boot: 3.2.0-SNAPSHOT
  • micrometer-tracing 1.12.0-M2

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 ?

like image 362
Jonathan Chevalier Avatar asked Feb 07 '26 22:02

Jonathan Chevalier


1 Answers

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))
like image 184
Jonathan Chevalier Avatar answered Feb 12 '26 05:02

Jonathan Chevalier