Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add response code to response timer metrics #3554

Merged
merged 3 commits into from
Jul 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3554.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `code` label to `synapse_http_server_response_time_seconds` prometheus metric
9 changes: 6 additions & 3 deletions synapse/http/request_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
)

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(
Expand Down Expand Up @@ -171,11 +172,13 @@ def stop(self, time_sec, request):
)
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
)

Expand Down