Skip to content

opentelemetry-instrumentation-dbapi: suppress async cursor spans#4622

Open
paragon wants to merge 2 commits into
open-telemetry:mainfrom
paragon:fix-dbapi-async-suppress-instrumentation
Open

opentelemetry-instrumentation-dbapi: suppress async cursor spans#4622
paragon wants to merge 2 commits into
open-telemetry:mainfrom
paragon:fix-dbapi-async-suppress-instrumentation

Conversation

@paragon

@paragon paragon commented May 22, 2026

Copy link
Copy Markdown

Honor suppress_instrumentation() in CursorTracer.traced_execution_async, matching the sync traced_execution path of CursorTracer.traced_execution.

Description

Fixes async DBAPI cursor execution not honoring suppress_instrumentation().

The sync CursorTracer.traced_execution() path already checks is_instrumentation_enabled() before creating spans, but CursorTracer.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

  • Bug fix (non-breaking change which fixes an issue)

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_async
  • uvx tox -e lint-instrumentation-dbapi
  • uvx ruff check instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py

Test configuration: macOS, Python 3.14.3.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@linux-foundation-easycla

linux-foundation-easycla Bot commented May 22, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

paragon added 2 commits May 22, 2026 10:17
Honor suppress_instrumentation() in CursorTracer.traced_execution_async, matching the sync traced_execution path.
@paragon paragon force-pushed the fix-dbapi-async-suppress-instrumentation branch from 45915c5 to a9a9d24 Compare May 22, 2026 14:17
@paragon paragon marked this pull request as ready for review May 22, 2026 14:29
@paragon paragon requested a review from a team as a code owner May 22, 2026 14:29
@tammy-baylis-swi tammy-baylis-swi moved this to Ready for review in Python PR digest Jun 4, 2026
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

2 participants