opentelemetry-instrumentation-dbapi: suppress async cursor spans#4622
Open
paragon wants to merge 2 commits into
Open
opentelemetry-instrumentation-dbapi: suppress async cursor spans#4622paragon wants to merge 2 commits into
paragon wants to merge 2 commits into
Conversation
Honor suppress_instrumentation() in CursorTracer.traced_execution_async, matching the sync traced_execution path.
45915c5 to
a9a9d24
Compare
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.
Honor
suppress_instrumentation()inCursorTracer.traced_execution_async, matching the sync traced_execution path ofCursorTracer.traced_execution.Description
Fixes async DBAPI cursor execution not honoring
suppress_instrumentation().The sync
CursorTracer.traced_execution()path already checksis_instrumentation_enabled()before creating spans, butCursorTracer.traced_execution_async()did not. This meant async DBAPI instrumentations that use this shared tracer could still emit spans while instrumentation was suppressed.This change adds the same suppression guard to the async execution path and adds a regression test to verify the async query method still runs while no span is exported.
Type of change
How Has This Been Tested?
Ran the DBAPI package tests and lint locally:
uvx tox -e py314-test-instrumentation-dbapi-wrapt2 -- instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py::TestDBApiIntegration::test_suppress_instrumentation_asyncuvx tox -e lint-instrumentation-dbapiuvx ruff check instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.pyTest configuration: macOS, Python 3.14.3.
Does This PR Require a Core Repo Change?
Checklist: