Skip to content

Expose capture_parameters in mysqlclient instrumentation - #4911

Open
saisharan0103 wants to merge 1 commit into
open-telemetry:mainfrom
saisharan0103:mergepath/issue-4790-opentelemetry-instrumentation-mysqlclien
Open

Expose capture_parameters in mysqlclient instrumentation#4911
saisharan0103 wants to merge 1 commit into
open-telemetry:mainfrom
saisharan0103:mergepath/issue-4790-opentelemetry-instrumentation-mysqlclien

Conversation

@saisharan0103

Copy link
Copy Markdown

The mysqlclient instrumentor delegates span creation and SQL parameter capture to the shared dbapi instrumentation, but it did not expose or forward dbapi's capture_parameters option. Calling MySQLClientInstrumentor().instrument(capture_parameters=True) silently dropped the option before dbapi.wrap_connect, and instrument_connection(..., capture_parameters=True) was not accepted or forwarded to dbapi.instrument_connection, so the dbapi layer always behaved as if parameter capture was disabled.

This change mirrors the existing dbapi and psycopg2 option threading by reading capture_parameters = kwargs.get("capture_parameters", False) in _instrument and passing it to dbapi.wrap_connect. It also adds a capture_parameters=False argument to instrument_connection and forwards it to dbapi.instrument_connection.

The module docstring now documents the option near the existing configuration sections. The mysqlclient mocked dbapi forwarding tests were extended to assert the default and explicit forwarded values, and a focused span assertion was added under stable database semantic conventions for db.query.parameter.<key> emission from the dbapi base.

Fixes #4790

ruff check instrumentation/opentelemetry-instrumentation-mysqlclient/src/opentelemetry/instrumentation/mysqlclient/__init__.py instrumentation/opentelemetry-instrumentation-mysqlclient/tests/test_mysqlclient_integration.py reports no new findings on the changed files.
Ran pytest -x locally with no new failures.

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Missing ID

  • ❌ The email address for the commit (7c4a25a) is not linked to the GitHub account, preventing the EasyCLA check. Consult this Help Article and GitHub Help to resolve. (To view the commit's email address, add .patch at the end of this PR page's URL.) For further assistance with EasyCLA, please visit our EasyCLA portal and chat with our support bot.

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.

opentelemetry-instrumentation-mysqlclient: expose capture_parameters

1 participant