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

4.1.5: Fully initialize OpenTelemetry items during start-up #9553

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

barchetta
Copy link
Member

Backport #9489 to Helidon 4.1.5

Description

Resolves #9488

The helidon-microprofile-telemetry component includes CDI producer methods for OpenTelemetry tracing types and the Helidon tracing counterparts backed by our OTel implementation.

Helidon provides these producer methods on an app-scoped bean. This works fine in a pure CDI world; the first time CDI needs to produce a tracer (for example), it prepares the OpenTelemetryProducer app-scoped bean which contains the producer methods. Part of that bean's post-construct code assigns the newly-created OTel tracer as the Helidon global tracer and subsequent retrievals of the global tracer return the correct, fully-featured tracer.

A problem can arise if user code accesses the global tracer before CDI has had to prepare the producer. In that case the code that accesses the global tracer triggers the creation of the default, no-op OTel tracer and assigns that to the global tracer.

This PR adds an observer method to the existing Helidon OTel telemetry CDI extension which forces CDI to create the producer bean during start-up. This ensures that the global tracer is set correctly before any user code gains control and potentially accesses the global tracer.

The PR also includes a test which reproduced the problem and ensures that the global tracer is set correctly as part of start-up, before user code gains control.

Documentation

No impact.

* Fully initialize OpenTelemetry items during start-up

* Invoke method on CDI proxy for tracer from extension observer method to ensure the bean is fully created

---------

Signed-off-by: Tim Quinn <[email protected]>
@barchetta barchetta added backport Issues that are merged into a single branch, but missing in either master or previous release 4.x Version 4.x labels Dec 3, 2024
@barchetta barchetta added this to the 4.1.5 milestone Dec 3, 2024
@barchetta barchetta self-assigned this Dec 3, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Dec 3, 2024
@barchetta barchetta mentioned this pull request Dec 3, 2024
12 tasks
@barchetta barchetta changed the title 4.1.5: Fully initialize OpenTelemetry items during start-up (#9489) 4.1.5: Fully initialize OpenTelemetry items during start-up Dec 3, 2024
@barchetta barchetta merged commit a5824b9 into helidon-io:helidon-4.1.x Dec 4, 2024
44 checks passed
@barchetta barchetta deleted the 4.1.5-9489-backport branch December 4, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x backport Issues that are merged into a single branch, but missing in either master or previous release OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants