Remove neutron_lib.db from db profiling projects

All db calls which are tracked by osprofiler are comming from
neutron and there is no need to enable sqlalchemy profiling for
both of them as this results in duplicated sql calls in osprofiler
reports.

Change-Id: I5b909b4181cd0fec432b78363c8a84ca40a5cf3e
This commit is contained in:
Slawek Kaplonski 2019-02-04 14:54:29 +01:00
parent 0347fe6f84
commit e806dcef88
3 changed files with 13 additions and 8 deletions

View File

@ -39,7 +39,6 @@ from neutron_lib.objects import exceptions as obj_exc
MAX_RETRIES = 20
OSPROFILER_TRACE_NAMES = {'neutron.db', 'neutron_lib.db'}
LOG = logging.getLogger(__name__)
_synchronized = lockutils.synchronized_with_prefix("neutron-")
_CTX_MANAGER = None
@ -69,9 +68,8 @@ def get_context_manager():
def _set_hook(engine):
if (profiler_opts.is_trace_enabled() and
profiler_opts.is_db_trace_enabled()):
for trace_name in OSPROFILER_TRACE_NAMES:
osprofiler.sqlalchemy.add_tracing(
sqlalchemy, engine, trace_name)
osprofiler.sqlalchemy.add_tracing(
sqlalchemy, engine, "neutron.db")
# TODO(ihrachys) the hook assumes options defined by osprofiler, and the only

View File

@ -213,7 +213,5 @@ class TestDBProfiler(_base.BaseTestCase):
osprofiler.sqlalchemy, 'add_tracing') as add_tracing:
engine_mock = mock.Mock()
db_api._set_hook(engine_mock)
self.assertEqual(2, len(add_tracing.mock_calls))
expected_calls = [mock.call(sqlalchemy, mock.ANY, n)
for n in db_api.OSPROFILER_TRACE_NAMES]
self.assertEqual(expected_calls, add_tracing.mock_calls)
add_tracing.assert_called_once_with(
sqlalchemy, mock.ANY, "neutron.db")

View File

@ -0,0 +1,9 @@
---
other:
- |
Module ``neutron_lib.db`` is now removed from db profiling projects so
database calls done from this module will not be tracked in osprofiler
results.
All db calls which are tracked by osprofiler are comming from
Neutron and this avoids having each call logged twice in osprofiler
report.