Refactor: From extractAndClear .. inject approach to extract .. clearAndInject #1047
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.
Draft to explore refactoring the approached used on messaging instrumentation (1) where context is first extracted and cleared from headers to later inject if needed, to an approach (2) where context is extracted to later clear context form headers if needed to then inject.
Messaging instrumentation has mainly 2 features on consumer side:
onConsume
that under (1) it extracts and clear headers, start/finish on-consume span, and injects context. AndnextSpan
that under (2) it extracts and clear headers, and creates a span from extracted context.Current effects of approach (1):
on-consume
feature we eventually inject context again, then this is not as critical.nextSpan
feature this restrict users to have only one child fromonConsume
span as we remove headers. This (potentially) could restrict users on how to continue a trace. There could be scenarios where users do a batch of operations after a message is consumed, requiring multiple spans to be created fromonConsume
span.Following approach (2) we can allow users to continue
onConsume
span multiple times.A side-effect of approach (2) is to reduce impact on current JMS consumer implementation:
onConsume
andnextSpan
onConsume
we remove this overhead fromnextSpan
feature.