Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wapkch opened this issue Oct 28, 2024 · 3 comments
Open

Comments

@wapkch
Copy link

wapkch commented Oct 28, 2024

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);
                }
            });
        }
    }
@shakuzen
Copy link
Member

@wapkch could you share what version of micrometer tracing you're using? Is this still an issue on the latest version?

@wapkch
Copy link
Author

wapkch commented Jan 1, 2025

@wapkch could you share what version of micrometer tracing you're using? Is this still an issue on the latest version?

After testing with the latest version (1.4.1), I noticed that the behavior between Brave and OTel is consistent. Async baggage propagation doesn’t work in either case, meaning the assertion mentioned above will fail. Is this behavior by design?

@marcingrzejszczak
Copy link
Contributor

So this is the way to go (not like in #928).

The problem is that Baggage is not automatically propagated between threads from Context Propagation unless you register

We describe this in the docs here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants