opentelemetry-instrumentation-pyramid: avoid duplicate traversal subscribers#4671
Closed
popsiclelmlm wants to merge 1 commit into
Closed
opentelemetry-instrumentation-pyramid: avoid duplicate traversal subscribers#4671popsiclelmlm wants to merge 1 commit into
popsiclelmlm wants to merge 1 commit into
Conversation
Assisted-by: GPT-5 Codex
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.
Summary
Prevent
opentelemetry-instrumentation-pyramidfrom registering duplicateBeforeTraversalsubscribers when Pyramid configuration includes run afterconfig.commit().Reproduction
A Pyramid include can call
config.commit(), which resets Pyramid action state. A laterconfig.include(...)creates another configurator and can run the OpenTelemetry callbacks include again. The new regression test simulates that flow and counts_before_traversalsubscriber registrations.Root cause
The instrumentation relied on Pyramid include de-duplication to avoid re-running
callbacks.includeme. Afterconfig.commit()resets action state, that de-duplication can no longer prevent the callbacks include from registering_before_traversalagain for the same registry.Changes
callbacks.includemeonly registers theBeforeTraversalsubscriber once.SETTING_TRACE_ENABLEDand tween insertion behavior on each include path.config.commit()before a later include.Tests
/Users/liumin/Documents/OpenSourceContributions/opentelemetry-python-contrib-pika-consumer-wrap/.venv-tox/bin/tox -e py314-test-instrumentation-pyramid/Users/liumin/Documents/OpenSourceContributions/opentelemetry-python-contrib-pika-consumer-wrap/.venv-tox/bin/tox -e lint-instrumentation-pyramid.tox/lint-instrumentation-pyramid/bin/ruff check instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py.tox/lint-instrumentation-pyramid/bin/ruff format --check instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.pygit diff --checkScreenshots/Logs
N/A. This is a unit-level instrumentation fix.
Type of change
Does This PR Require a Core Repo Change?
Checklist: