Skip to content

aiopg: capture db.query.parameter.<key> under new semconv#4806

Draft
ocelotl wants to merge 2 commits into
open-telemetry:mainfrom
ocelotl:issue_4796_aiopg_db_query_parameter
Draft

aiopg: capture db.query.parameter.<key> under new semconv#4806
ocelotl wants to merge 2 commits into
open-telemetry:mainfrom
ocelotl:issue_4796_aiopg_db_query_parameter

Conversation

@ocelotl

@ocelotl ocelotl commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a capture_parameters option to the aiopg instrumentor and records parameters as db.query.parameter.<key> under the new database semconv (legacy blob under old semconv), not on batch operations. Reuses the shared DB-API _populate_span.

Part of #4787. Fixes #4796.

Stacked on #4788 (the shared dbapi base + _set_db_query_parameters helper). Until #4788 merges, this PR's diff is cumulative and includes those base changes; it will be rebased onto main afterwards.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit tests: 28 passed (6 new).

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

ocelotl added 2 commits July 11, 2026 11:53
Add a shared _set_db_query_parameters helper that emits one
db.query.parameter.<key> attribute per prepared-statement parameter,
keyed by name for named parameters and by 0-based index for positional
parameters, with values stringified.

Wire it into the dbapi CursorTracer so that, when capture_parameters is
enabled, the legacy db.statement.parameters attribute is reported only in
the old semconv while db.query.parameter.<key> is reported in the new
(stable) database semconv. Parameters are not captured on batch
operations (executemany), per the semantic conventions.
Add a capture_parameters option to AiopgInstrumentor and thread it
through the aiopg wrappers into AiopgIntegration. When enabled, the
async execution path emits db.statement.parameters under the old
semconv and db.query.parameter.<key> under the new semconv, reusing the
shared dbapi _populate_span logic. Query parameters are not captured for
batch operations (executemany).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-aiopg: capture db.query.parameter.<key>

1 participant