Skip to content

Psycopg semconv optin tests#4838

Open
henry3260 wants to merge 2 commits into
open-telemetry:mainfrom
henry3260:psycopg-semconv-optin-tests
Open

Psycopg semconv optin tests#4838
henry3260 wants to merge 2 commits into
open-telemetry:mainfrom
henry3260:psycopg-semconv-optin-tests

Conversation

@henry3260

@henry3260 henry3260 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Description

Since psycopg instruments both sync and async connection paths, this adds four
tests mirroring the merged mysql (#4810) / mysqlclient (#4834) pattern:

  • test_semconv_stable / test_semconv_stable_async (database,http):
    assert only stable attributes are emitted (db.system.name, db.namespace,
    db.query.text, server.address, server.port) and legacy ones
    (db.system, db.name, db.statement, db.user, net.peer.*) are absent
  • test_semconv_dup / test_semconv_dup_async (database/dup,http/dup):
    assert both legacy and stable attributes are emitted with correct values

Since psycopg maps connection attributes through the nested info object
(info.dbname, info.host, info.port, info.user), the existing mock
connections are extended with MockConnectionWithInfo and
MockAsyncConnectionWithInfo to expose them.

Type of change

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

How Has This Been Tested?

  • tox -e py312-test-instrumentation-psycopg-1 — 25 passed, 3 skipped (21 existing + 4 new; skips are pre-existing t-string tests requiring Python 3.14+)
  • tox -e lint-instrumentation-psycopg — pylint 10.00/10
  • pre-commit run ruff / ruff-format — clean

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 (not required: test-only change)

…est coverage

Cover database,http and database/dup,http/dup opt-in modes for both the
sync and async connection paths, verifying stable-only and dual-emission
span attributes, mirroring the pattern from open-telemetry#4810.
@henry3260
henry3260 marked this pull request as ready for review July 18, 2026 18:59
@henry3260
henry3260 requested a review from a team as a code owner July 18, 2026 18:59
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.

1 participant