Skip to content

Baggage is lost when explicitly setting parent observation #882

Open
@jamesmoessis

Description

@jamesmoessis

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%   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions