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.x Allow users to direct Helidon to use an existing global OpenTelemetry instance rather than create its own #9205

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

tjquinno
Copy link
Member

@tjquinno tjquinno commented Aug 26, 2024

Description

Resolves #9204

This PR adds the ability of Helidon MP users to indicate that some code other than Helidon will create the global OpenTelemetry instance and Helidon MP should simply use that instance rather than trying to create it.

This PR affects the public API of Helidon in these ways:

  • New config setting io.helidon.telemetry.otel.use-existing-instance indicating whether Helidon MP should use the global instance of OTel which some other code has already created. Defaults to false so Helidon MP creates the global OTel instance itself.
  • The pre-existing public typeHelidonOpenTelemetry.AgentDetector has a new public method useExistingGlobalOpenTelemetry. This method combines the results of the existing isAgentPresent method with a check of the new config setting. If isAgentPresent returns true then this new method returns true regardless of the config setting. Otherwise the method essentially returns the config setting (which, as mentioned above, defaults to false).
  • OpenTelemetryProducer now invokes the new AgentDetector#useExistingGlobalOpenTelemetry method (instead of isAgentPresent as it used to) to decide whether to create a new global OTel instance or use whatever existing one is present.

If otel.agent.present is true and io.helidon.telemetry.otel.use-existing-instance is false the agent setting takes precedence and Helidon uses the global OTel instance which the agent provided.

The PR also includes some new tests.

Documentation

There is no doc impact currently but, at some point, we need to add documentation for the OpenTelemetry tracing provider and this enhancement would be discussed there.

@tjquinno tjquinno self-assigned this Aug 26, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 26, 2024
@tjquinno tjquinno changed the title 4.x use existing otel 4.x Allow users to direct Helidon to use an existing global OpenTelemetry instance rather than create its own Aug 27, 2024
@tjquinno tjquinno merged commit bffe01e into helidon-io:main Aug 29, 2024
44 checks passed
@tjquinno tjquinno deleted the 4.x-use-existing-otel branch August 29, 2024 17:11
tjquinno added a commit to tjquinno/helidon that referenced this pull request Aug 29, 2024
…metry` instance rather than create its own (helidon-io#9205)

* Allow explicit use/avoidance of existing OTel instance via configuration

* Clarify config property name

* Refer to 'telemetry' instead of 'tracing' in property name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow use of pre-existing OpenTelemetry global instance without OTel Java agent
2 participants