open-telemetry / open-telemetry/opentelemetry-python-contrib

`opentelemetry-instrumentation-mysql`: expose `capture_parameters`

Open Beginner friendly
#4,789 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

Part of #4787 (global db.query.parameter.<key> tracking issue).

Background

mysql builds on the dbapi base, so once the dbapi sub-issue lands it already
knows how to emit db.query.parameter.<key> correctly — but only when
capture_parameters=True. The MySQL instrumentor never exposes that option, so
users currently have no way to enable parameter capture.

psycopg2 already exposes capture_parameters and is the reference
implementation for this change.

What to do

Thread a capture_parameters option through the instrumentor, mirroring
psycopg2:

  • In MySQLInstrumentor._instrument, read
    capture_parameters = kwargs.get("capture_parameters", False) and pass it to
    dbapi.wrap_connect(...).
  • In MySQLInstrumentor.instrument_connection, add a capture_parameters
    parameter and pass it to dbapi.instrument_connection(...).
  • Document the option in the module docstring.

No parameter-formatting logic lives here — it all comes from the dbapi base.

Acceptance criteria

  • MySQLInstrumentor().instrument(capture_parameters=True) and
    instrument_connection(conn, capture_parameters=True) both enable capture.
  • With capture enabled, spans carry db.query.parameter.<key> under the new
    semconv and db.statement.parameters under the old semconv (via the base).
  • Default remains no parameter capture.

Tests

  • Verify capture_parameters is forwarded to the dbapi layer for both
    instrument() and instrument_connection().
  • Verify db.query.parameter.<key> appears under the new semconv when enabled.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare the psycopg2 instrumentor with MySQLInstrumentor._instrument and instrument_connection, then trace the dbapi wrapping calls and the module docstring. Add tests for forwarding capture_parameters through both entry points and verify the new and old semconv attributes while the default remains disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, python
Domain
database
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.