Skip to content

Conversation

xiangtianyu
Copy link
Contributor

@xiangtianyu xiangtianyu commented Sep 25, 2025

resolves to #6273
AsyncEventBus can cause trace IDs to appear as "0000000000000000". The issue is resolved by removing the event bus class from the OpenTelemetry agent's ignore list, as AsyncEventBus relies on an executor that the agent already supports.

https://github.com/google/guava/blob/d7240c0eedbef92ca40377e864a77a1e30e91474/guava/src/com/google/common/eventbus/Subscriber.java#L66-L75

@xiangtianyu xiangtianyu requested a review from a team as a code owner September 25, 2025 08:03
@laurit
Copy link
Contributor

laurit commented Sep 25, 2025

@xiangtianyu do you know whether this PR resolves #6273?

@xiangtianyu
Copy link
Contributor Author

@xiangtianyu do you know whether this PR resolves #6273?

I build a demo like this:

public class MyNotifier {
    private static final Logger log = LoggerFactory.getLogger(MyNotifier.class);

    @Subscribe
    public void handleEvent(String event) {
        log.info("Received event: {}", event);
        log.info("traceId: {}", Span.current().getSpanContext().getTraceId());
        log.info("spanId: {}", Span.current().getSpanContext().getSpanId());
    }
}

@RequestMapping("eventbus")
    public String eventbus() {
        log.info("Posting event to EventBus");
        log.info("traceId: {}", Span.current().getSpanContext().getTraceId());
        log.info("spanId: {}", Span.current().getSpanContext().getSpanId());
        asyncEventBus.post("Hello, AsyncEventBus!");
        return "eventbus";
    }

The result of the print is like:
before allow class:
image

after allow class:
image

@xiangtianyu
Copy link
Contributor Author

xiangtianyu commented Sep 26, 2025

BTW, if i want to create bus event instrumentation, it should be a new independent instrumentation "guava-eventbus" or a part of guava instrumentation?

@laurit laurit changed the title fix async eventbus traceId 00000 Fix context propagation for guava AsyncEventBus Sep 26, 2025
@laurit
Copy link
Contributor

laurit commented Sep 26, 2025

BTW, if i want to create bus event instrumentation, it should be a new independent instrumentation "guava-eventbus" or a part of guava instrumentation?

I'd add it under the guava instrumentation.

@laurit
Copy link
Contributor

laurit commented Sep 26, 2025

would it be possible to add a regression test for this?

@xiangtianyu
Copy link
Contributor Author

would it be possible to add a regression test for this?

I don't know what to do. Add a test for eventbus in guava instrumentation? Or any other ways?

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@xiangtianyu
Copy link
Contributor Author

I tried to add a test for this case in guava instrumentation

@laurit laurit added this to the v2.21.0 milestone Sep 29, 2025
@trask trask merged commit 8de9ca4 into open-telemetry:main Sep 29, 2025
167 of 169 checks passed
Copy link
Contributor

otelbot bot commented Sep 29, 2025

Thank you for your contribution @xiangtianyu! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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

Successfully merging this pull request may close these issues.

3 participants