open-telemetry / opentelemetry-python-contrib

OpenTelemetry instrumentation for Python modules
https://opentelemetry.io
Apache License 2.0
739 stars 612 forks source link

Update SQLAlchemy instrumentor tests to work with SQLAlchemy 2 #2975

Closed tammy-baylis-swi closed 2 weeks ago

tammy-baylis-swi commented 2 weeks ago

What problem do you want to solve?

The method sqlalchemy.engine.Connection.execute still accepts a regular string as query statement in SQLAlchemy 1.4, but it's no longer possible in SQLAlchemy 2:

Deprecated since version 2.0: passing a string to Connection.execute() is deprecated and will be removed in version 2.0. Use the text() construct with Connection.execute(), or the Connection.exec_driver_sql() method to invoke a driver-level SQL string.

See also https://docs.sqlalchemy.org/en/14/core/connections.html#sqlalchemy.engine.Connection.execute

This is an issue because several of the SQLAlchemy instrumentor tests still pass str instead of sqlalchemy.text, and the tests will fail if run with SQLAlchemy 2.

Describe the solution you'd like

I will update the tests.

Describe alternatives you've considered

No response

Additional Context

Related to https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2970

Would you like to implement a fix?

Yis