Merge "Remove neutron_lib.db from db profiling projects"

This commit is contained in:
Zuul 2019-02-20 17:13:47 +00:00 committed by Gerrit Code Review
commit 044ca8e3e4
3 changed files with 13 additions and 8 deletions

View File

@ -38,7 +38,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
@ -68,9 +67,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.