fix(pymssql): Complete semconv stability migration for attributes set in wrapped_connection#4592
Merged
xrmx merged 6 commits intoMay 18, 2026
Conversation
The pymssql instrumentation's wrapped_connection() was setting net.peer.name, net.peer.port, and db.user using hardcoded legacy attribute keys, bypassing the semconv stability helpers introduced in open-telemetry#4109. Replace hardcoded keys with _set_db_user, _set_http_net_peer_name_client, and _set_http_peer_port_client so that OTEL_SEMCONV_STABILITY_OPT_IN correctly emits stable attributes (server.address, server.port, etc.). Also updates existing test assertions for net.peer.port from string to int, matching the behavior of set_int_attribute used by the helper.
xrmx
approved these changes
May 18, 2026
xrmx
left a comment
Contributor
There was a problem hiding this comment.
This looks good to me, please add a fragment for the changelog that also list the change in the type of net.peer.port
Contributor
|
@luke6Lh43 Please also fix lint and run |
xrmx
reviewed
May 18, 2026
…st_pymssql_integration.py Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…st_pymssql_integration.py Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
emdneto
approved these changes
May 18, 2026
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.
fix(pymssql): Complete semconv stability migration for attributes set in
wrapped_connectionDescription
This PR fixes the incomplete semantic convention stability (
OTEL_SEMCONV_STABILITY_OPT_IN) implementation inopentelemetry-instrumentation-pymssql.Problem:
When PR #4109 migrated the base
dbapiinstrumentation to support stable semantic conventions,pymssql's customwrapped_connection()method was not updated. This method directly setsnet.peer.name,net.peer.port, anddb.userusing hardcoded string keys because pymssql's connection object doesn't expose connection attributes through the standard path.As a result, even with
OTEL_SEMCONV_STABILITY_OPT_IN=database,http, spans still emit legacy attribute names (net.peer.name,net.peer.port,db.user) instead of their stable equivalents (server.address,server.port,db.client.user).Fix:
Replace the hardcoded attribute assignments with the semconv-aware helper functions:
self.span_attributes["db.user"] = user→_set_db_user(...)self.span_attributes["net.peer.name"] = host→_set_http_net_peer_name_client(...)self.span_attributes["net.peer.port"] = port→_set_http_peer_port_client(...)These helpers respect the configured opt-in mode and emit old, new, or both attribute keys accordingly.
Changes
instrumentation/opentelemetry-instrumentation-pymssql/src/opentelemetry/instrumentation/pymssql/__init__.py_set_db_user,_set_http_net_peer_name_client,_set_http_peer_port_clientfromopentelemetry.instrumentation.dbapiinstrumentation/opentelemetry-instrumentation-pymssql/tests/test_pymssql_integration.pyuse_semconv_opt_in()context manager for opt-in testingnet.peer.portassertions:"1433"(string) →1433(int), since_set_http_peer_port_clientusesset_int_attributetest_semconv_stable: verifies thatdatabase,httpopt-in emits only stable attributes (server.address,server.port,db.client.user)test_semconv_dup: verifies thatdatabase/dup,http/dupopt-in emits both old and new attribute keysTesting
All 10 tests pass:
Related Issues
Fixes #4591
Type of Change
Checklist