Hi,

Sorry about this as this seems like a tricky bug which I have re-created in https://github.com/davidmelia/spring-boot-kafka-consumer-tracing/tree/hooks-test-error (run MyApplicationTests)

Using @AutoConfigureObservability and Hooks.enableAutomaticContextPropagation() and management.tracing.baggage.correlation.fields then I get the following error when running integration tests

java.lang.AssertionError: Misalignment: popped updateScope false !=  expected false
    at brave.baggage.CorrelationFlushScope.popCurrentUpdateScope(CorrelationFlushScope.java:86) ~[brave-5.14.1.jar:na]
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
    *__checkpoint ⇢ org.springframework.web.filter.reactive.ServerHttpObservationFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ HTTP GET "/home" [ExceptionHandlingWebHandler]
Original Stack Trace:
        at brave.baggage.CorrelationFlushScope.popCurrentUpdateScope(CorrelationFlushScope.java:86) ~[brave-5.14.1.jar:na]
        at brave.baggage.CorrelationFlushScope.close(CorrelationFlushScope.java:37) ~[brave-5.14.1.jar:na]
        at io.micrometer.tracing.brave.bridge.BraveScope.close(BraveCurrentTraceContext.java:114) ~[micrometer-tracing-bridge-brave-1.0.2.jar:1.0.2]

My test :

@AutoConfigureObservability
@SpringBootTest
@AutoConfigureWebTestClient
class MyApplicationTests {

    @Autowired
    private WebTestClient webTestClient;

    @Test
    void contextLoads() {
      webTestClient.get().uri("/home").exchange().expectStatus().isOk();
      Hooks.enableAutomaticContextPropagation();
          webTestClient.get().uri("/home").exchange().expectStatus().is5xxServerError();       
    }


}

Interestingly if I remove management.tracing.baggage.correlation.fields=Customer-Name then the error goes away.

I think this is related too https://github.com/spring-projects/spring-boot/issues/34201

Thanks

Comment From: wilkinsona

Duplicates #34326 and https://github.com/micrometer-metrics/tracing/issues/175.