opentelemetry-instrumentation-mysql: add semconv stability opt-in test coverage#4810
Open
anneheartrecord wants to merge 2 commits into
Open
opentelemetry-instrumentation-mysql: add semconv stability opt-in test coverage#4810anneheartrecord wants to merge 2 commits into
anneheartrecord wants to merge 2 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.
xrmx
approved these changes
Jul 13, 2026
Contributor
|
@anneheartrecord please add a changelog entry in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: