summary refs log tree commit diff
path: root/synapse/http/server.py
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-12-04 15:29:31 +0000
committerMark Haines <mjark@negativecurvature.net>2015-12-04 15:29:31 +0000
commitbd0fa9e2d2131c5e390b4c2267528c2f3955588c (patch)
tree76af375be7dc7bb0df4692c416459fed26ef56fb /synapse/http/server.py
parentMerge pull request #420 from matrix-org/markjh/resource_usage (diff)
parentAdd metrics to track the cpu on the main thread consumed by each type of request (diff)
downloadsynapse-bd0fa9e2d2131c5e390b4c2267528c2f3955588c.tar.xz
Merge pull request #421 from matrix-org/markjh/resource_metrics
Add metrics to track the cpu on the main thread consumed by each type…
Diffstat (limited to 'synapse/http/server.py')
-rw-r--r--synapse/http/server.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/http/server.py b/synapse/http/server.py
index ef75be742c..06fb53707b 100644
--- a/synapse/http/server.py
+++ b/synapse/http/server.py
@@ -53,6 +53,14 @@ response_timer = metrics.register_distribution(
     labels=["method", "servlet"]
 )
 
+response_ru_utime = metrics.register_distribution(
+    "response_ru_utime", labels=["method", "servlet"]
+)
+
+response_ru_stime = metrics.register_distribution(
+    "response_ru_stime", labels=["method", "servlet"]
+)
+
 _next_request_id = 0
 
 
@@ -221,6 +229,15 @@ class JsonResource(HttpServer, resource.Resource):
                 self.clock.time_msec() - start, request.method, servlet_classname
             )
 
+            try:
+                context = LoggingContext.current_context()
+                ru_utime, ru_stime = context.get_resource_usage()
+
+                response_ru_utime.inc_by(ru_utime, request.method, servlet_classname)
+                response_ru_stime.inc_by(ru_stime, request.method, servlet_classname)
+            except:
+                pass
+
             return
 
         # Huh. No one wanted to handle that? Fiiiiiine. Send 400.