summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2018-07-19 10:25:18 +0100
committerGitHub <noreply@github.com>2018-07-19 10:25:18 +0100
commit6f62a6ef215fbcde16bd4c73e9bfbd02b40cf7bb (patch)
treee243df56660e0768eaff94e3c2fefc0cf720198f
parentMerge pull request #3559 from matrix-org/rav/pep8_config (diff)
parentpep8 (diff)
downloadsynapse-6f62a6ef215fbcde16bd4c73e9bfbd02b40cf7bb.tar.xz
Merge pull request #3554 from matrix-org/erikj/response_metrics_code
Add response code to response timer metrics
-rw-r--r--changelog.d/3554.feature1
-rw-r--r--synapse/http/request_metrics.py9
2 files changed, 7 insertions, 3 deletions
diff --git a/changelog.d/3554.feature b/changelog.d/3554.feature
new file mode 100644
index 0000000000..b00397872c
--- /dev/null
+++ b/changelog.d/3554.feature
@@ -0,0 +1 @@
+Add `code` label to `synapse_http_server_response_time_seconds` prometheus metric
diff --git a/synapse/http/request_metrics.py b/synapse/http/request_metrics.py
index f24b4b949c..588e280571 100644
--- a/synapse/http/request_metrics.py
+++ b/synapse/http/request_metrics.py
@@ -38,7 +38,8 @@ outgoing_responses_counter = Counter(
 )
 
 response_timer = Histogram(
-    "synapse_http_server_response_time_seconds", "sec", ["method", "servlet", "tag"]
+    "synapse_http_server_response_time_seconds", "sec",
+    ["method", "servlet", "tag", "code"],
 )
 
 response_ru_utime = Counter(
@@ -171,11 +172,13 @@ class RequestMetrics(object):
                 )
                 return
 
-        outgoing_responses_counter.labels(request.method, str(request.code)).inc()
+        response_code = str(request.code)
+
+        outgoing_responses_counter.labels(request.method, response_code).inc()
 
         response_count.labels(request.method, self.name, tag).inc()
 
-        response_timer.labels(request.method, self.name, tag).observe(
+        response_timer.labels(request.method, self.name, tag, response_code).observe(
             time_sec - self.start
         )