Commit d9592fc4 by cahrens

Make the code robust to the request cache being cleared.

parent 91f1923d
...@@ -114,7 +114,11 @@ class MonitoringMemoryMiddleware(object): ...@@ -114,7 +114,11 @@ class MonitoringMemoryMiddleware(object):
""" """
Returns a formatted prefix for logging for the given request. Returns a formatted prefix for logging for the given request.
""" """
return u"{} request '{} {} {}'".format(prefix, request.method, request.path, self._cache[self.guid_key]) # After a celery task runs, the request cache is cleared. So if celery
# tasks are running synchronously (CELERY_ALWAYS _EAGER), "guid_key"
# will no longer be in the request cache when process_response executes.
cached_guid = self._cache.get(self.guid_key) or u"without_guid"
return u"{} request '{} {} {}'".format(prefix, request.method, request.path, cached_guid)
def _memory_data(self, log_prefix): def _memory_data(self, log_prefix):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment