open-telemetry / open-telemetry/opentelemetry-python-contrib
`opentelemetry-instrumentation-asyncpg`: capture `db.query.parameter.<key>`
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
asyncpg does not build on the dbapi base. It independently captures
parameters as the non-standard db.statement.parameters blob (a single
stringified value) when capture_parameters=True. It already uses the semconv
stability opt-in mechanism (_StabilityMode / _report_new).
What to do
- Reuse the shared
_set_db_query_parametershelper from
opentelemetry.instrumentation._semconv(added in the dbapi sub-issue). - When
capture_parametersis enabled:- emit
db.statement.parametersonly under the old semconv; - emit
db.query.parameter.<key>under the new semconv via the helper.
- emit
- asyncpg passes positional query arguments; key them by 0-based index.
- Do not capture parameters for the batch execution paths (e.g.
executemany).
Acceptance criteria
- Old semconv:
db.statement.parametersunchanged; nodb.query.parameter.*. - New semconv:
db.query.parameter.<key>emitted; nodb.statement.parameters. database/dup: both present.- Values captured as strings; batch executions do not emit
db.query.parameter.*.
Tests
- Cover old / new / dup modes and the batch case.
- Verify exact attribute names and string value types against the spec.
- Exercise the async execute paths.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the asyncpg instrumentation's asynchronous execute paths and the shared _set_db_query_parameters helper in opentelemetry.instrumentation._semconv. Run or extend the instrumentation tests for old, new, and dup stability modes plus batch execution; done means exact attribute names, string values, and no parameter attributes on batch paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100