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

Commit

Permalink
Add metrics to track the cpu on the main thread consumed by each type…
Browse files Browse the repository at this point in the history
… of request
  • Loading branch information
Mark Haines committed Dec 4, 2015
1 parent 3c85a31 commit 99e1d67
Showing 1 changed file with 17 additions and 0 deletions.
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

0 comments on commit 99e1d67

Please sign in to comment.