Skip to content

Commit 5cb4dab

Browse files
Use sqlalchemy version in sqlalchemy commenter instead of opentelemetry library version (#2404)
* Use sqlalchemy version in sqlalchemy commenter instead of opentelemetry library version The SqlAlchemy commenter is currently using the library version in the comment it emits, e.g.: ``` { 'db_driver': 'psycopg2', 'db_framework': 'sqlalchemy:0.45b0' } ``` We should instead be using the sqlalchemy version here, as SqlCommenter did before * Fix lint * Fix lint * Add CHANGELOG entry --------- Co-authored-by: Diego Hurtado <[email protected]>
1 parent c644f0d commit 5cb4dab

File tree

2 files changed

+5
-2
lines changed
  • instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy

2 files changed

+5
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- Use sqlalchemy version in sqlalchemy commenter instead of opentelemetry library version
11+
([#2404](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2404))
12+
1013
### Added
1114

1215
- `opentelemetry-instrumentation-pika` Instrumentation for `channel.consume()` (supported

instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
import re
1616
import weakref
1717

18+
import sqlalchemy
1819
from sqlalchemy.event import ( # pylint: disable=no-name-in-module
1920
listen,
2021
remove,
2122
)
2223

2324
from opentelemetry import trace
24-
from opentelemetry.instrumentation.sqlalchemy.version import __version__
2525
from opentelemetry.instrumentation.sqlcommenter_utils import _add_sql_comment
2626
from opentelemetry.instrumentation.utils import _get_opentelemetry_values
2727
from opentelemetry.semconv.trace import NetTransportValues, SpanAttributes
@@ -227,7 +227,7 @@ def _before_cur_exec(
227227
commenter_data = {
228228
"db_driver": conn.engine.driver,
229229
# Driver/framework centric information.
230-
"db_framework": f"sqlalchemy:{__version__}",
230+
"db_framework": f"sqlalchemy:{sqlalchemy.__version__}",
231231
}
232232

233233
if self.commenter_options.get("opentelemetry_values", True):

0 commit comments

Comments
 (0)