diff options
author | Mark Haines <mjark@negativecurvature.net> | 2015-12-04 14:15:41 +0000 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2015-12-04 14:15:41 +0000 |
commit | 3c85a317d603bcbf2cc9c0b5b4ebcef1c9014db8 (patch) | |
tree | 9e531f36780ec5c39bd56671f6cac4afb1d10877 /synapse/app/homeserver.py | |
parent | Merge pull request #419 from matrix-org/markjh/reuse_captcha_client (diff) | |
parent | Add comments to explain why we are hardcoding RUSAGE_THREAD (diff) | |
download | synapse-3c85a317d603bcbf2cc9c0b5b4ebcef1c9014db8.tar.xz |
Merge pull request #420 from matrix-org/markjh/resource_usage
Track the cpu used in the main thread by each logging context
Diffstat (limited to 'synapse/app/homeserver.py')
-rwxr-xr-x | synapse/app/homeserver.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index cd7a52ec07..58c679bbfd 100755 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -499,13 +499,23 @@ class SynapseRequest(Request): self.start_time = int(time.time() * 1000) def finished_processing(self): + + try: + context = LoggingContext.current_context() + ru_utime, ru_stime = context.get_resource_usage() + except: + ru_utime, ru_stime = (0, 0) + self.site.access_logger.info( "%s - %s - {%s}" - " Processed request: %dms %sB %s \"%s %s %s\" \"%s\"", + " Processed request: %dms (%dms, %dms)" + " %sB %s \"%s %s %s\" \"%s\"", self.getClientIP(), self.site.site_tag, self.authenticated_entity, int(time.time() * 1000) - self.start_time, + int(ru_utime * 1000), + int(ru_stime * 1000), self.sentLength, self.code, self.method, |