Skip to content

Commit

Permalink
Use sqlalchemy version in sqlalchemy commenter instead of opentelemet…
Browse files Browse the repository at this point in the history
…ry 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 <ocelotl@users.noreply.github.com>
  • Loading branch information
nicknicolini and ocelotl authored Apr 22, 2024
1 parent c644f0d commit 5cb4dab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Use sqlalchemy version in sqlalchemy commenter instead of opentelemetry library version
([#2404](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2404))

### Added

- `opentelemetry-instrumentation-pika` Instrumentation for `channel.consume()` (supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import re
import weakref

import sqlalchemy
from sqlalchemy.event import ( # pylint: disable=no-name-in-module
listen,
remove,
)

from opentelemetry import trace
from opentelemetry.instrumentation.sqlalchemy.version import __version__
from opentelemetry.instrumentation.sqlcommenter_utils import _add_sql_comment
from opentelemetry.instrumentation.utils import _get_opentelemetry_values
from opentelemetry.semconv.trace import NetTransportValues, SpanAttributes
Expand Down Expand Up @@ -227,7 +227,7 @@ def _before_cur_exec(
commenter_data = {
"db_driver": conn.engine.driver,
# Driver/framework centric information.
"db_framework": f"sqlalchemy:{__version__}",
"db_framework": f"sqlalchemy:{sqlalchemy.__version__}",
}

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

0 comments on commit 5cb4dab

Please sign in to comment.