summary refs log tree commit diff
path: root/synapse/http/server.py
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-12-08 11:52:35 +0000
committerMark Haines <mjark@negativecurvature.net>2015-12-08 11:52:35 +0000
commit219027f580774dedebf0074cf25500d424b451f3 (patch)
treeb0876351b0c892e23c81ac5a3d85f329d34df7b6 /synapse/http/server.py
parentMerge pull request #423 from matrix-org/markjh/archived_flag (diff)
parentTrack the time spent in the database per request. (diff)
downloadsynapse-219027f580774dedebf0074cf25500d424b451f3.tar.xz
Merge pull request #429 from matrix-org/markjh/db_counters
Track the time spent in the database per request.
Diffstat (limited to 'synapse/http/server.py')
-rw-r--r--synapse/http/server.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/http/server.py b/synapse/http/server.py
index 06fb53707b..c44bdfc888 100644
--- a/synapse/http/server.py
+++ b/synapse/http/server.py
@@ -61,6 +61,15 @@ response_ru_stime = metrics.register_distribution(
     "response_ru_stime", labels=["method", "servlet"]
 )
 
+response_db_txn_count = metrics.register_distribution(
+    "response_db_txn_count", labels=["method", "servlet"]
+)
+
+response_db_txn_duration = metrics.register_distribution(
+    "response_db_txn_duration", labels=["method", "servlet"]
+)
+
+
 _next_request_id = 0
 
 
@@ -235,6 +244,12 @@ class JsonResource(HttpServer, resource.Resource):
 
                 response_ru_utime.inc_by(ru_utime, request.method, servlet_classname)
                 response_ru_stime.inc_by(ru_stime, request.method, servlet_classname)
+                response_db_txn_count.inc_by(
+                    context.db_txn_count, request.method, servlet_classname
+                )
+                response_db_txn_duration.inc_by(
+                    context.db_txn_duration, request.method, servlet_classname
+                )
             except:
                 pass