Skip to content

Baggage Tags are not propagated unless explicit getBaggage call to Tracer #933

@mehmetcabuk

Description

@mehmetcabuk

Describe the bug
I am testing micrometer baggage tag field with a simple code block in a method in a RestController. I provide the configured header in the rest request, but I can't see the request on Jaeger server UI.
If I add a line to check if the baggage field is actually in the tracer, then it is automatically propagated and I can see it in the Jaeger server UI. I do not set anything, i just make a simple get call.

Environment

  • Micrometer version 1.14.2 (latest as of now)
  • Micrometer registry (prometheus:1.14.2)
  • OS: MacOS
  • Java version: 23

To Reproduce
How to reproduce the bug:

My Application.Properties Config:

management.endpoints.web.exposure.include=*
management.tracing.sampling.probability=1.0

management.tracing.enabled=true
management.tracing.baggage.enabled=true
management.tracing.baggage.remote-fields=X-TEST-HEADER
management.tracing.baggage.tag-fields=X-TEST-HEADER

management.otlp.tracing.transport=grpc
management.otlp.tracing.endpoint=http://localhost:4317
management.otlp.tracing.export.enabled=true

============================

My build.gradle (relevant parts)

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.4.1'
    id 'io.spring.dependency-management' version '1.1.7'
}

ext {
    set('springCloudVersion', "2024.0.0")
    set('springBootVersion', "3.4.1")
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'io.micrometer:micrometer-registry-prometheus'
    implementation 'net.logstash.logback:logstash-logback-encoder:8.0'

    implementation 'io.micrometer:micrometer-tracing-bridge-otel'
    implementation 'io.opentelemetry:opentelemetry-exporter-otlp'


    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'

    testImplementation platform('org.junit:junit-bom:5.10.0')
    testImplementation 'org.junit.jupiter:junit-jupiter'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
        mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
        mavenBom "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.11.0"
    }
}

============================

SampleController.java Class:

@RestController
@RequestMapping("/v1/sample")
public class SampleController {
    private final Tracer tracer;

    public SampleController(Tracer tracer) {
        this.tracer = tracer;
    }

    @GetMapping
    public SampleResponse getSampleData() {
        //tracer.getBaggage("X-TEST-HEADER");
        // Create a sample DTO object
        SampleDto sampleDto = new SampleDto("Sample Name", "Sample Description", 100);

        // Return a response with the DTO
        return new SampleResponse("Success", sampleDto);
    }
}

Edit: I am adding logs below. As you can see, it detects the header as a baggage and it says i will propagate, but it does not. (i.m.t.o.p.BaggageTextMapPropagator : Will propagate new baggage context for entries {X-TEST-HEADER=123456})

2025-01-06T03:25:25.741Z DEBUG 1 --- [template-microservice] [io-10000-exec-2] [ ] t.p.B3PropagatorExtractorMultipleHeaders : Invalid TraceId in B3 header: null'. Returning INVALID span context.
2025-01-06T03:25:25.742761979Z 2025-01-06T03:25:25.742Z DEBUG 1 --- [template-microservice] [io-10000-exec-2] [ ] t.p.B3PropagatorExtractorMultipleHeaders : Invalid TraceId in B3 header: null'. Returning INVALID span context.
2025-01-06T03:25:25.747971678Z 2025-01-06T03:25:25.747Z DEBUG 1 --- [template-microservice] [io-10000-exec-2] [ ] i.m.t.o.p.BaggageTextMapPropagator : Will propagate new baggage context for entries {X-TEST-HEADER=123456}
2025-01-06T03:25:29.277241677Z 2025-01-06T03:25:29.276Z DEBUG 1 --- [template-microservice] [jaeger:4317/...] [ ] okhttp3.internal.http2.Http2 : >> CONNECTION 505249202a20485454502f322e300d0a0d0a534d0d0a0d0a
2025-01-06T03:25:29.278486332Z 2025-01-06T03:25:29.277Z DEBUG 1 --- [template-microservice] [jaeger:4317/...] [ ] okhttp3.internal.http2.Http2 : >> 0x00000000 6 SETTINGS
2025-01-06T03:25:29.279119259Z 2025-01-06T03:25:29.278Z DEBUG 1 --- [template-microservice] [jaeger:4317/...] [ ] okhttp3.internal.http2.Http2 : >> 0x00000000 4 WINDOW_UPDATE
2025-01-06T03:25:29.282437312Z

============================

Expected behavior
Even if I didn't have the line "tracer.getBaggage("X-TEST-HEADER");", I should be able to see the header propagated to Jaeger and I should be able to see it in Jaeger Server UI.

If I comment out the tracer.getBaggage code above, I don't see the header under tags section of Jaeger Server UI.
If I have the tracer.getBaggage code in the Controller, I can see the header under tags section of Jaeger Server UI.

Additional context
I don't have any other class other than the DTO mentioned above and the MainApplication.java class (@SpringBootApplication), and this class just has static main method.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions