summary refs log tree commit diff
path: root/synapse/http
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-02-09 15:20:56 +0000
committerKegan Dougal <kegan@matrix.org>2015-02-09 15:20:56 +0000
commit53557fc53259631d71055ef2ab8a6916b00d229b (patch)
tree208db19fb5bbcc5416e669bc496adc49acdcb1a7 /synapse/http
parentFix bugs so lazy room joining works as intended. (diff)
parentMerge pull request #55 from matrix-org/profiling (diff)
downloadsynapse-53557fc53259631d71055ef2ab8a6916b00d229b.tar.xz
Merge branch 'develop' into application-services
Diffstat (limited to 'synapse/http')
-rw-r--r--synapse/http/matrixfederationclient.py3
-rw-r--r--synapse/http/server.py23
2 files changed, 23 insertions, 3 deletions
diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py
index 8559d06b7f..056d446e42 100644
--- a/synapse/http/matrixfederationclient.py
+++ b/synapse/http/matrixfederationclient.py
@@ -169,8 +169,9 @@ class MatrixFederationHttpClient(object):
         else:
             # :'(
             # Update transactions table?
+            body = yield readBody(response)
             raise HttpResponseException(
-                response.code, response.phrase, response
+                response.code, response.phrase, body
             )
 
         defer.returnValue(response)
diff --git a/synapse/http/server.py b/synapse/http/server.py
index 0f6539e1be..6d084fa33c 100644
--- a/synapse/http/server.py
+++ b/synapse/http/server.py
@@ -69,9 +69,10 @@ class JsonResource(HttpServer, resource.Resource):
 
     _PathEntry = collections.namedtuple("_PathEntry", ["pattern", "callback"])
 
-    def __init__(self):
+    def __init__(self, hs):
         resource.Resource.__init__(self)
 
+        self.clock = hs.get_clock()
         self.path_regexs = {}
 
     def register_path(self, method, path_pattern, callback):
@@ -111,6 +112,7 @@ class JsonResource(HttpServer, resource.Resource):
             This checks if anyone has registered a callback for that method and
             path.
         """
+        code = None
         try:
             # Just say yes to OPTIONS.
             if request.method == "OPTIONS":
@@ -130,6 +132,13 @@ class JsonResource(HttpServer, resource.Resource):
                         urllib.unquote(u).decode("UTF-8") for u in m.groups()
                     ]
 
+                    logger.info(
+                        "Received request: %s %s",
+                        request.method, request.path
+                    )
+
+                    start = self.clock.time_msec()
+
                     code, response = yield path_entry.callback(
                         request,
                         *args
@@ -145,9 +154,11 @@ class JsonResource(HttpServer, resource.Resource):
                 logger.info("%s SynapseError: %s - %s", request, e.code, e.msg)
             else:
                 logger.exception(e)
+
+            code = e.code
             self._send_response(
                 request,
-                e.code,
+                code,
                 cs_exception(e),
                 response_code_message=e.response_code_message
             )
@@ -158,6 +169,14 @@ class JsonResource(HttpServer, resource.Resource):
                 500,
                 {"error": "Internal server error"}
             )
+        finally:
+            code = str(code) if code else "-"
+
+            end = self.clock.time_msec()
+            logger.info(
+                "Processed request: %dms %s %s %s",
+                end-start, code, request.method, request.path
+            )
 
     def _send_response(self, request, code, response_json_object,
                        response_code_message=None):