opentelemetry-instrumentation-mysql: add semconv stability opt-in test coverage#4810
opentelemetry-instrumentation-mysql: add semconv stability opt-in test coverage#4810anneheartrecord wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d8cc31a3e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds missing test coverage in the MySQL instrumentation package to ensure DB-API–driven semantic convention stability behavior remains correct across OTEL_SEMCONV_STABILITY_OPT_IN modes, preventing regressions in emitted span attributes.
Changes:
- Added a small helper context manager to set
OTEL_SEMCONV_STABILITY_OPT_INand reset the semconv stability cache for deterministic tests. - Added two integration tests verifying attribute output for
database,http(stable-only keys) anddatabase/dup,http/dup(stable + legacy keys). - Extended the MySQL connection mock to include a
uservalue sodb.userbehavior can be asserted in dup mode.
|
@anneheartrecord please add a changelog entry in |
|
Done — added |
Description
The mysql instrumentation delegates span creation to the shared dbapi layer, which already handles the database semconv stability migration (#4109). However, unlike pymssql (#4592), the mysql test suite had no coverage of the
OTEL_SEMCONV_STABILITY_OPT_INmodes, so regressions in what the instrumentation emits per mode would go unnoticed.This adds two tests mirroring the merged pymssql 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 absenttest_semconv_dup(database/dup,http/dup): asserts both legacy and stable attributes are emittedVerified locally that the current dbapi-based behavior matches the database semconv spec in default, stable and dup modes.
Fixes #1632
Type of change
How Has This Been Tested?
pytest instrumentation/opentelemetry-instrumentation-mysql/tests/— 17 passed (15 existing + 2 new)ruff check/ruff format --check(ruff 0.14.1) — cleanDoes This PR Require a Core Repo Change?
Checklist: