micrometer-metrics / tracing

Provides tracing abstractions over tracers and tracing system reporters.
https://micrometer.io
Apache License 2.0
252 stars 46 forks source link

Baggage is lost when explicitly setting parent observation #882

Open jamesmoessis opened 4 weeks ago

jamesmoessis commented 4 weeks ago

Using: id("org.springframework.boot") version "3.3.5"

I would expect baggage to be carried over when setting a parent observation. Currently it is lost. I am using the otel tracing bridge.

Example:

    @GetMapping("observation")
    public Mono<String> observation() {
        String baggageBefore = tracer.getBaggage("key").get();
        Observation parent = observationRegistry.getCurrentObservation();
        Observation o = Observation.createNotStarted("child", observationRegistry).parentObservation(parent);
        try(Observation.Scope ignored = o.openScope()) {
            String baggageAfter = tracer.getBaggage("key").get(); // expect "val" but is null
            return Mono.just("baggagebefore="+baggageBefore+", baggageAfter="+baggageAfter);
        }
    }

Full minimal reproduction in this repo: https://github.com/jamesmoessis/baggage-bug-demo

Reproduce by running it then:

$ curl http://localhost:8080/observation -H 'baggage: key=val'
baggagebefore=val, baggageAfter=null%