Clean thread local profiler object after usage

Currently profiler is initiated in the osprofiler wsgi
middleware, but is not cleaned up after this. This leaded to the
fact, that there is profiler object initiated if the thread
is reused, even if there was no hmac_key passed via next API
request to the traced service. For most of OpenStack projects this
was not influencing the fucntionality, as all requests were processed
in separated greenlets, but in Keystone there is reusable thread
pool. This leaded to the situation, when DB calls were continued
to be traced even if the original request was finished for a while
ago.

Change-Id: Ie84e1b28ac61c03b2619530e5d619855c5072207
This commit is contained in:
Dina Belova 2016-03-18 13:33:36 +03:00
parent a9425a9dc4
commit 347f6a7ba9

View File

@ -123,5 +123,8 @@ class WsgiMiddleware(object):
"scheme": request.scheme
}
}
with profiler.Trace(self.name, info=info):
return request.get_response(self.application)
try:
with profiler.Trace(self.name, info=info):
return request.get_response(self.application)
finally:
profiler._clean()