Delete profiler object when request completes

When a request that is being profiled completes and the response is
received, the middleware expires the profiling cookie. It also needs
to delete the profiling object that holds the base_id UUID so a new
base_id will be created for the next profile. Otherwise the same
base_id is used for subsequent queries and they become merged togther
in the database.

Change-Id: I379cebfa2ed5282c96df0e255a8ba04c65a8523c
Closes-Bug: #1777486
Depends-On: https://review.openstack.org/578362
This commit is contained in:
Stuart Grace 2018-06-15 17:56:25 +01:00
parent 3a579e643a
commit 2e2ef6a8d0
3 changed files with 5 additions and 2 deletions

View File

@ -71,7 +71,7 @@ oslo.policy==1.30.0
oslo.serialization==2.18.0
oslo.service==1.24.0
oslo.utils==3.33.0
osprofiler==1.4.0
osprofiler==2.3.0
Paste==2.0.2
PasteDeploy==1.5.0
pbr==2.0.0

View File

@ -141,5 +141,8 @@ class ProfilerMiddleware(object):
response.set_cookie('profile_page', max_age=0, path=path)
def process_response(self, request, response):
if profiler.get() is not None:
profiler.clean()
self.clear_profiling_cookies(request, response)
return response

View File

@ -25,7 +25,7 @@ oslo.i18n>=3.15.3 # Apache-2.0
oslo.policy>=1.30.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0
osprofiler>=1.4.0 # Apache-2.0
osprofiler>=2.3.0 # Apache-2.0
Pint>=0.5 # BSD
pymongo!=3.1,>=3.0.2 # Apache-2.0
pyScss!=1.3.5,>=1.3.4 # MIT License