Fix sqlalchemy with osprofiler

Breakage seen in magnum-capi-helm unit tests after [1].

[1]: https://review.opendev.org/c/openstack/magnum/+/927446

Closes-Bug: #2089934

Change-Id: I3e5560dd487525d9566930772b0c56d52d974500
(cherry picked from commit ea2619f462)
This commit is contained in:
Michal Nasiadka 2024-11-29 15:14:15 +01:00 committed by Pierre Riteau
parent 5927785d45
commit b47479272a

View File

@ -64,7 +64,8 @@ def _session_for_write():
def _wrap_session(session):
if CONF.profiler.enabled and CONF.profiler.trace_sqlalchemy:
if (hasattr(CONF, 'profiler') and CONF.profiler.enabled and
CONF.profiler.trace_sqlalchemy):
session = profiler_sqlalchemy.wrap_session(sa, session)
return session