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

Commit

Permalink
Merge pull request #421 from matrix-org/markjh/resource_metrics
Browse files Browse the repository at this point in the history
Add metrics to track the cpu on the main thread consumed by each type…
  • Loading branch information
NegativeMjark committed Dec 4, 2015
2 parents 3c85a31 + 99e1d67 commit bd0fa9e
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 bd0fa9e

Please sign in to comment.