Slight clean-up of recent baggage and span scope fix #8258
Merged
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
Further fine-tuning to earlier fix for #8187
The earlier fix properly make sure that, when activating a span, the scope resulting from making an Otel context current correctly reflected both the span information and the baggage.
Because of the way Otel contexts work, we have to create two new contexts, one with the span information, and then another that adds the baggage information. The earlier fix made each of these two contexts "current" on the Otel context stack. That worked, because the context corresponding to the second "active" scope reflected the span and baggage info. Then, when the Helidon
Scope
was closed the earlier fix closed both scopes internally.But there is no need to create two scopes and make both of them current and then close both of them later when the Helidon
Scope
is closed.This fine-tuning still creates two contexts (necessarily, as noted above) but only uses the second one (that knows about both span and baggage info). It creates only one scope by making that "all-knowing" context current. Then, when the Helidon
Scope
is closed, there's only the one OtelScope
to close.This PR also fixes a small bug in the earlier fix which failed to create an "all-knowing" Otel context when creating a context for the Helidon
SpanContext
Documentation
No doc impact.