Allow configuration to trigger span listener notification of injected OpenTelemetry Tracer
and Span
#9607
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Resolves #9079
Developers can assign the config setting
telemetry.injection-type
tonative
orneutral
:native
- the default and the prior behavior - Helidon injects native OTelTracer
andSpan
objects - span listeners are not notified of state changes related to injected objectsneutral
- Helidon injects wrappers around the native OTel types which delegate to the underlying OTel object but also notify any registeredSpanListener
objects (which receive parameters that are the Helidon neutral types:Tracer
,Span.Builder
,Span
,Scope
).Developers need to opt into the new behavior because pre-existing applications might use
instanceof
or similar type-sensitive constructs on injected values referring to OTel implementation types. If Helidon were to change now to always inject wrapped objects in order to notify span listeners then those constructs would no longer work as before.Highlights of the changes
io.helidon.tracing.Wrapper
interface which declares theunwrap
method. Theneutral
injected objects implementWrapper
so developers, if needed, can cast injected objects toWrapper
and then unwrap them to get to the underlying OTel objects.injection-type
setting. We do not have pre-existing telemetry-based configuration that is Helidon-specific. (There areotel.*
settings which Helidon supports in compliance with the MP Telemetry spec but the new setting is Helidon-specific and not related to OTel so should not be under theotel
section.)Tracer
orSpan
etc. wrapper around the native OTel object. Most methods in the wrapper classes simply delegate to the native OTel object. The exception: any method that causes changes of state (which the span listeners observe)--such as starting or ending a span or activating or closing a scope--invoke the Helidon wrapper which does the notification and delegates to the OTel object.Documentation
PR includes doc updates.