diff options
author | Dina Belova <dbelova@mirantis.com> | 2015-11-11 15:51:01 +0300 |
---|---|---|
committer | Dina Belova <dbelova@mirantis.com> | 2015-11-12 09:17:45 +0000 |
commit | cabf79d44c77a9259481cabfa888e99730fb40b0 (patch) | |
tree | 5a4c5f05e5e7b50a349241f378a88fd8e8046051 /osprofiler/web.py | |
parent | 9c18d7ef6b886a9e320937117c0b1e57b154eeeb (diff) | |
download | osprofiler-0.3.1.tar.gz |
Make api-paste.ini config optional0.3.1
* osprofiler.web.WsgiMiddleware now treats hmac_keys as optional arg
* add hmac_keys argument to enable() method to use it later in
OpenStack services setup
Change-Id: Ib544d2732c7307bc5405b4336eda80120d2f43af
Diffstat (limited to 'osprofiler/web.py')
-rw-r--r-- | osprofiler/web.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/osprofiler/web.py b/osprofiler/web.py index 053c132..209cc27 100644 --- a/osprofiler/web.py +++ b/osprofiler/web.py @@ -40,6 +40,7 @@ def get_trace_id_headers(): _DISABLED = False +_HMAC_KEYS = None def disable(): @@ -52,16 +53,17 @@ def disable(): _DISABLED = True -def enable(): +def enable(hmac_keys=None): """Enable middleware.""" - global _DISABLED + global _DISABLED, _HMAC_KEYS _DISABLED = False + _HMAC_KEYS = utils.split(hmac_keys or "") class WsgiMiddleware(object): """WSGI Middleware that enables tracing for an application.""" - def __init__(self, application, hmac_keys, enabled=False): + def __init__(self, application, hmac_keys=None, enabled=False): """Initialize middleware with api-paste.ini arguments. :application: wsgi app @@ -100,7 +102,7 @@ class WsgiMiddleware(object): trace_info = utils.signed_unpack(request.headers.get("X-Trace-Info"), request.headers.get("X-Trace-HMAC"), - self.hmac_keys) + _HMAC_KEYS or self.hmac_keys) if not self._trace_is_valid(trace_info): return request.get_response(self.application) |