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

Add metrics to track the cpu on the main thread consumed by each type… #421

Merged
merged 1 commit into from
Dec 4, 2015
Merged
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
17 changes: 17 additions & 0 deletions synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
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


Expand Down Expand Up @@ -221,6 +229,15 @@ def _async_render(self, request):
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.
Expand Down