Skip to content

Psycopg2 semconv optin tests#4837

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

Psycopg2 semconv optin tests#4837
henry3260 wants to merge 2 commits into
open-telemetry:mainfrom
henry3260:psycopg2-semconv-optin-tests

Conversation

@henry3260

@henry3260 henry3260 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Description

This adds two tests mirroring the merged mysql (#4810) / mysqlclient (#4834)
pattern:

  • test_semconv_stable (database,http): asserts 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 (database/dup,http/dup): asserts both legacy and stable
    attributes are emitted with correct values

Since psycopg2 maps connection attributes through the nested info object
(info.dbname, info.host, info.port, info.user), a MockConnectionWithInfo
mock is added to expose them. The two new tests push TestPostgresqlIntegration
past pylint's 20-public-method limit, so the class gets the
# pylint: disable=too-many-public-methods annotation used elsewhere in the repo.

Type of change

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

How Has This Been Tested?

  • pytest instrumentation/opentelemetry-instrumentation-psycopg2/tests/test_psycopg2_integration.py (with psycopg2-binary) — 19 passed (17 existing + 2 new)
  • pylint==4.0.5 --rcfile .pylintrc — 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)

…test coverage

Cover database,http and database/dup,http/dup opt-in modes, 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 15:52
@henry3260
henry3260 requested a review from a team as a code owner July 18, 2026 15:52
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