Add ability to trace SQL transactions with profiler
Closes-Bug: #2082944 Change-Id: I8781359e338ffb44e5f55211bec147000a2097cb
This commit is contained in:
@@ -41,6 +41,7 @@ from oslo_utils import importutils
|
|||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from sqlalchemy import MetaData
|
from sqlalchemy import MetaData
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
@@ -77,6 +78,14 @@ context_manager = enginefacade.transaction_context()
|
|||||||
|
|
||||||
context_manager.configure()
|
context_manager.configure()
|
||||||
|
|
||||||
|
if (
|
||||||
|
osprofiler_sqlalchemy and
|
||||||
|
CONF.profiler.enabled and
|
||||||
|
CONF.profiler.trace_sqlalchemy
|
||||||
|
):
|
||||||
|
context_manager.append_on_engine_create(
|
||||||
|
lambda engine: osprofiler_sqlalchemy.add_tracing(sa, engine, "db"))
|
||||||
|
|
||||||
|
|
||||||
def get_engine():
|
def get_engine():
|
||||||
return context_manager.writer.get_engine()
|
return context_manager.writer.get_engine()
|
||||||
|
5
releasenotes/notes/bug-2082944-sqlalchemy-tracing.yml
Normal file
5
releasenotes/notes/bug-2082944-sqlalchemy-tracing.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Added tracing to SQLAlchemy engine if profiler is enabled and
|
||||||
|
profiler.trace_sqlalchemy is set to true.
|
Reference in New Issue
Block a user