test(mysql): provide concrete DBAPI connection attributes in mocks#4116
Merged
xrmx merged 14 commits intoopen-telemetry:mainfrom Feb 20, 2026
Merged
test(mysql): provide concrete DBAPI connection attributes in mocks#4116xrmx merged 14 commits intoopen-telemetry:mainfrom
xrmx merged 14 commits intoopen-telemetry:mainfrom
Conversation
Contributor
Author
|
This PR only updates tests and does not change runtime behavior or public APIs. |
xrmx
reviewed
Jan 22, 2026
instrumentation/opentelemetry-instrumentation-mysql/tests/test_mysql_integration.py
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-mysql/tests/test_mysql_integration.py
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-mysql/tests/test_mysql_integration.py
Show resolved
Hide resolved
Contributor
|
Please also do a |
- Introduce make_mysql_commenter_mocks helper - Remove duplicated MagicMock setup - Preserve test assertions and behavior - Improve readability and maintainability
Contributor
Author
|
@tammy-baylis-swi Thanks for the heads up,I ran |
instrumentation/opentelemetry-instrumentation-mysql/tests/test_mysql_integration.py
Show resolved
Hide resolved
… attribute type warnings
tammy-baylis-swi
approved these changes
Feb 19, 2026
Contributor
tammy-baylis-swi
left a comment
There was a problem hiding this comment.
Thanks this lgtm! xrmx or another Maintainer will also need to review this.
xrmx
reviewed
Feb 20, 2026
instrumentation/opentelemetry-instrumentation-mysql/tests/test_mysql_integration.py
Outdated
Show resolved
Hide resolved
sightseeker
added a commit
to sightseeker/opentelemetry-python-contrib
that referenced
this pull request
Mar 11, 2026
…pen-telemetry#4116) * test(mysql): provide concrete DBAPI connection attributes in mocks * test(mysql): pass concrete attributes via MagicMock helpers * test(mysql): refactor mocks and remove redundant attribute assignments * changelog: add mysql test mock fix entry * test(mysql): refactor SQL commenter mocks into helper * test(mysql): refactor SQL commenter mocks into helper - Introduce make_mysql_commenter_mocks helper - Remove duplicated MagicMock setup - Preserve test assertions and behavior - Improve readability and maintainability * test(mysql): use concrete DBAPI connection attributes in mocks to fix attribute type warnings * Update instrumentation/opentelemetry-instrumentation-mysql/tests/test_mysql_integration.py --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
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
This PR updates the MySQL instrumentation integration tests to provide concrete DBAPI connection attributes (
host,port,database) in mocked connection and cursor objects.Previously, several tests emitted OpenTelemetry warnings due to
MagicMockvalues being used for attributes such asdb.name,net.peer.name, andnet.peer.port. These warnings were noisy but did not cause test failures.By setting realistic primitive values in the mocks, the tests now run without attribute type warnings, improving signal-to-noise ratio while keeping behavior unchanged.
Fixes #4114
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Ran MySQL instrumentation integration tests locally: tox -e py310-test-instrumentation-mysql-1
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.