fix(pyramid): prevent double BeforeTraversal subscriber after config.commit()#4773
Closed
krrishapatel wants to merge 1 commit into
Closed
fix(pyramid): prevent double BeforeTraversal subscriber after config.commit()#4773krrishapatel wants to merge 1 commit into
krrishapatel wants to merge 1 commit into
Conversation
…commit() Guard _traced_init against re-registering the BeforeTraversal subscriber when config.commit() clears Pyramid's action_state deduplication. Uses a sentinel on the registry to ensure callbacks are included only once. Fixes open-telemetry#4663 Assisted-by: Claude Opus 4.6
Contributor
|
Duplicated of #4741, not cool to waste reviewers time with duplicated PRs. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes #4663
When any Pyramid library calls
config.commit()during itsincludeme(e.g.tomb_routeson everyadd_simple_route), the action state is cleared. A subsequentconfig.include()then triggers_traced_initon a child Configurator and registers the_before_traversalsubscriber a second time, causing OpenTelemetry context corruption — child spans become orphaned as separate traces.This adds a sentinel attribute on the registry to ensure
_before_traversalis registered only once per application, regardless of how many timesconfig.commit()is called during configuration.Type of change
How Has This Been Tested?
Added two regression tests in
TestDoubleSubscriberRegistration:test_commit_does_not_double_register_subscriber— verifies only oneBeforeTraversalhandler exists afterconfig.commit()+ subsequent includestest_normal_operation_after_commit— verifies tracing still works correctly in this scenarioAll 33 existing pyramid tests continue to pass.
Does This PR Require a Core Repo Change?
Checklist:
Assisted-by: Claude Opus 4.6