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
Copy link
Copy Markdown

@paragon paragon commented May 22, 2026

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
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 22, 2026

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant