diff --git a/neutron_lib/db/api.py b/neutron_lib/db/api.py index 9374b12ab..cb121e6e5 100644 --- a/neutron_lib/db/api.py +++ b/neutron_lib/db/api.py @@ -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 diff --git a/neutron_lib/tests/unit/db/test_api.py b/neutron_lib/tests/unit/db/test_api.py index 32b347c16..a6fe81114 100644 --- a/neutron_lib/tests/unit/db/test_api.py +++ b/neutron_lib/tests/unit/db/test_api.py @@ -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") diff --git a/releasenotes/notes/remove-neutron-lib-from-db-profiling-38436898d8e45b37.yaml b/releasenotes/notes/remove-neutron-lib-from-db-profiling-38436898d8e45b37.yaml new file mode 100644 index 000000000..63f716d71 --- /dev/null +++ b/releasenotes/notes/remove-neutron-lib-from-db-profiling-38436898d8e45b37.yaml @@ -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.