summary refs log tree commit diff
path: root/synapse/http/client.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-10-30 01:21:33 +0000
committerMark Haines <mark.haines@matrix.org>2014-10-30 01:21:33 +0000
commitb29517bd013b82302b1a73072da8bfc39564dc1a (patch)
tree363ac928a18f2432b6d53c27dde2f2efb34b16a8 /synapse/http/client.py
parentfix mobile CSS layout (diff)
downloadsynapse-b29517bd013b82302b1a73072da8bfc39564dc1a.tar.xz
Add a request-id to each log line
Diffstat (limited to 'synapse/http/client.py')
-rw-r--r--synapse/http/client.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/synapse/http/client.py b/synapse/http/client.py
index 46c90dbb76..8bda42364b 100644
--- a/synapse/http/client.py
+++ b/synapse/http/client.py
@@ -16,11 +16,14 @@
 
 from twisted.internet import defer, reactor
 from twisted.internet.error import DNSLookupError
-from twisted.web.client import _AgentBase, _URI, readBody, FileBodyProducer, PartialDownloadError
+from twisted.web.client import (
+    _AgentBase, _URI, readBody, FileBodyProducer, PartialDownloadError
+)
 from twisted.web.http_headers import Headers
 
 from synapse.http.endpoint import matrix_endpoint
 from synapse.util.async import sleep
+from synapse.util.logcontext import PreserveLoggingContext
 
 from syutil.jsonutil import encode_canonical_json
 
@@ -106,16 +109,17 @@ class BaseHttpClient(object):
                 producer = body_callback(method, url_bytes, headers_dict)
 
             try:
-                response = yield self.agent.request(
-                    destination,
-                    endpoint,
-                    method,
-                    path_bytes,
-                    param_bytes,
-                    query_bytes,
-                    Headers(headers_dict),
-                    producer
-                )
+                with PreserveLoggingContext():
+                    response = yield self.agent.request(
+                        destination,
+                        endpoint,
+                        method,
+                        path_bytes,
+                        param_bytes,
+                        query_bytes,
+                        Headers(headers_dict),
+                        producer
+                    )
 
                 logger.debug("Got response to %s", method)
                 break