Skip to content

Async baggage propagation failed after baggage is closed when using Brave #879

@wapkch

Description

@wapkch

When using micrometer-tracing-bridge-brave, async baggage propagation not work after the BaggageInScope has closed, but if using micrometer-tracing-bridge-otel, it worked.

Here is an example:

    @GetMapping
    public void test() {
        ExecutorService executorService = ContextExecutorService.wrap(Executors.newCachedThreadPool(), ContextSnapshot::captureAll);
        try (BaggageInScope baggage = tracer.getBaggage("xyz").makeCurrent("123")) {
            executorService.execute(() -> {
                try {
                    Thread.sleep(3000);
                    String s = tracer.getBaggage("xyz").get();
                    Assert.state(s.equals("123"), "Baggage should be propagated"); // work when using otel, not work when using brave
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            });
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    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