mirror of
https://mau.dev/maunium/synapse.git
synced 2024-09-10 20:02:21 +02:00
Merge pull request #421 from matrix-org/markjh/resource_metrics
Add metrics to track the cpu on the main thread consumed by each type…
This commit is contained in:
commit
bd0fa9e2d2
1 changed files with 17 additions and 0 deletions
|
@ -53,6 +53,14 @@ response_timer = metrics.register_distribution(
|
|||
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
|
||||
|
||||
|
||||
|
@ -221,6 +229,15 @@ class JsonResource(HttpServer, resource.Resource):
|
|||
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.
|
||||
|
|
Loading…
Reference in a new issue