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

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

Open
#4,796 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

aiopg reuses parts of the dbapi machinery but provides its own async
traced_execution in aiopg_integration.py, so it does not inherit the base
parameter-capture logic. It does not capture parameters at all today and does
not expose a capture_parameters option.

What to do

  • Add a capture_parameters option to the aiopg instrumentor and thread it
    through to the aiopg integration, mirroring how dbapi / psycopg2 expose it.
  • In aiopg's traced_execution, when capture_parameters is enabled:
    • emit db.statement.parameters only under the old semconv;
    • emit db.query.parameter.<key> under the new semconv using the shared
      _set_db_query_parameters helper from
      opentelemetry.instrumentation._semconv.
  • Do not capture parameters on batch operations (executemany).
  • Reuse the base _populate_span behavior where practical to avoid duplicating
    logic.

Acceptance criteria

  • A user can enable parameter capture via capture_parameters.
  • Old semconv: only db.statement.parameters.
  • New semconv: only db.query.parameter.<key>.
  • database/dup: both.
  • Values captured as strings; batch operations do not emit
    db.query.parameter.*.

Tests

  • Cover old / new / dup modes and the batch case for the async execute paths.
  • Verify exact attribute names and string value types against the spec.

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

Start with the aiopg instrumentor and its custom async traced_execution in aiopg_integration.py, then compare parameter handling in dbapi and psycopg2. Use the shared _set_db_query_parameters helper and cover old, new, dup, and batch modes in the async execute tests. Done means the specified attributes and string values are emitted, with no parameter attributes for executemany.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.