Merge "Make profiler.clean() public method"

This commit is contained in:
Zuul 2018-07-09 16:39:57 +00:00 committed by Gerrit Code Review
commit 6d68170f72
4 changed files with 9 additions and 9 deletions

View File

@ -31,7 +31,7 @@ from osprofiler import notifier
__local_ctx = threading.local() __local_ctx = threading.local()
def _clean(): def clean():
__local_ctx.profiler = None __local_ctx.profiler = None

View File

@ -28,7 +28,7 @@ from osprofiler.tests import test
class ProfilerGlobMethodsTestCase(test.TestCase): class ProfilerGlobMethodsTestCase(test.TestCase):
def test_get_profiler_not_inited(self): def test_get_profiler_not_inited(self):
profiler._clean() profiler.clean()
self.assertIsNone(profiler.get()) self.assertIsNone(profiler.get())
def test_get_profiler_and_init(self): def test_get_profiler_and_init(self):
@ -40,7 +40,7 @@ class ProfilerGlobMethodsTestCase(test.TestCase):
self.assertEqual(p.get_id(), "2") self.assertEqual(p.get_id(), "2")
def test_start_not_inited(self): def test_start_not_inited(self):
profiler._clean() profiler.clean()
profiler.start("name") profiler.start("name")
def test_start(self): def test_start(self):
@ -50,7 +50,7 @@ class ProfilerGlobMethodsTestCase(test.TestCase):
p.start.assert_called_once_with("name", info="info") p.start.assert_called_once_with("name", info="info")
def test_stop_not_inited(self): def test_stop_not_inited(self):
profiler._clean() profiler.clean()
profiler.stop() profiler.stop()
def test_stop(self): def test_stop(self):

View File

@ -31,8 +31,8 @@ class WebTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(WebTestCase, self).setUp() super(WebTestCase, self).setUp()
profiler._clean() profiler.clean()
self.addCleanup(profiler._clean) self.addCleanup(profiler.clean)
def test_get_trace_id_headers_no_hmac(self): def test_get_trace_id_headers_no_hmac(self):
profiler.init(None, base_id="y", parent_id="z") profiler.init(None, base_id="y", parent_id="z")
@ -61,10 +61,10 @@ class WebTestCase(test.TestCase):
class WebMiddlewareTestCase(test.TestCase): class WebMiddlewareTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(WebMiddlewareTestCase, self).setUp() super(WebMiddlewareTestCase, self).setUp()
profiler._clean() profiler.clean()
# it's default state of _ENABLED param, so let's set it here # it's default state of _ENABLED param, so let's set it here
web._ENABLED = None web._ENABLED = None
self.addCleanup(profiler._clean) self.addCleanup(profiler.clean)
def tearDown(self): def tearDown(self):
web.enable() web.enable()

View File

@ -131,4 +131,4 @@ class WsgiMiddleware(object):
with profiler.Trace(self.name, info=info): with profiler.Trace(self.name, info=info):
return request.get_response(self.application) return request.get_response(self.application)
finally: finally:
profiler._clean() profiler.clean()