You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Re-register Reactor hook after Hooks.resetOnEachOperator() - #20845
After an application calls Hooks.resetOnEachOperator(), the agent no longer propagates the context through Reactor operators: a subscriber of an externally driven Flux.create publisher no longer sees the context that was current when it subscribed, and nothing brings it back.
HooksInstrumentation is meant to prevent that: it re-registers the hook at the end of Hooks.resetOnEachOperator. But ContextPropagationOperator.registerOnEachOperator() returns early when its static enabled flag is set, and the application's own reset doesn't go through the operator, so the flag stays set and the registration is ignored.
This adds a second advice for the no-argument resetOnEachOperator() that resets the operator state and registers again. The keyed resetOnEachOperator(String) and the type initializers keep the existing advice. There is no API change.
HooksResetTest calls Hooks.resetOnEachOperator() twice and checks the context after each; it fails without the change (the second assertion, after the first reset), and also checks that resetting an unrelated hook key changes nothing.
The agent installs its onEachOperator hook again when the application resets
the hooks, but ContextPropagationOperator still considered the hook
registered and ignored the registration, so the context stopped being
propagated after Hooks.resetOnEachOperator().
Assisted-by: Claude Opus 5.5
Re-registering with a newly built operator after Hooks.resetOnEachOperator()
added a new async operation end strategy to the registry on every reset,
since each operator owns its own strategy and the registry unregisters
by identity. The agent now keeps one operator and resets and registers
that same operator.
Assisted-by: Claude Opus 5.5
[Javaagent] Non-blocking: the keyed overload has the fixed signature resetOnEachOperator(String). The matching rule in .github/instructions/javaagent.instructions.md requires takesArguments(Type...) for fixed signatures using accessible java.base types. Use takesArguments(String.class) instead of matching only the argument count.
[Javaagent] Non-blocking: match the keyed overload with takesArguments(String.class) rather than its argument count. The fixed-signature rule in .github/instructions/javaagent.instructions.md:71–73 requires typed matchers for accessible java.base parameters, even when the advice does not use them.
Thank you for your contribution @DDINGJOO! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
After an application calls
Hooks.resetOnEachOperator(), the agent no longer propagates the context through Reactor operators: a subscriber of an externally drivenFlux.createpublisher no longer sees the context that was current when it subscribed, and nothing brings it back.HooksInstrumentationis meant to prevent that: it re-registers the hook at the end ofHooks.resetOnEachOperator. ButContextPropagationOperator.registerOnEachOperator()returns early when its staticenabledflag is set, and the application's own reset doesn't go through the operator, so the flag stays set and the registration is ignored.This adds a second advice for the no-argument
resetOnEachOperator()that resets the operator state and registers again. The keyedresetOnEachOperator(String)and the type initializers keep the existing advice. There is no API change.HooksResetTestcallsHooks.resetOnEachOperator()twice and checks the context after each; it fails without the change (the second assertion, after the first reset), and also checks that resetting an unrelated hook key changes nothing.