diff options
author | Erik Johnston <erik@matrix.org> | 2018-05-22 09:34:26 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-05-22 09:34:26 +0100 |
commit | c435b0b44172efe485ae1401deb8adca2e774d3c (patch) | |
tree | 4a1c6292bd9e95bbc8d93a5b99f268ad158cfe85 /synapse | |
parent | Move in_flight_requests_count to be a callback metric (diff) | |
download | synapse-c435b0b44172efe485ae1401deb8adca2e774d3c.tar.xz |
Don't store context
Diffstat (limited to '')
-rw-r--r-- | synapse/http/request_metrics.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/synapse/http/request_metrics.py b/synapse/http/request_metrics.py index 8cb23f4d64..5917c83958 100644 --- a/synapse/http/request_metrics.py +++ b/synapse/http/request_metrics.py @@ -230,7 +230,7 @@ class RequestMetrics(object): """Updates the in flight metrics with values from this request. """ - diff = self._request_stats.update() + diff = self._request_stats.update(self.start_context) in_flight_requests_ru_utime.inc_by( diff.ru_utime, self.method, self.name, @@ -258,13 +258,12 @@ class _RequestStats(object): """ __slots__ = [ - "context", "ru_utime", "ru_stime", + "ru_utime", "ru_stime", "db_txn_count", "db_txn_duration_ms", "db_sched_duration_ms", ] - def __init__(self, context, ru_utime, ru_stime, db_txn_count, + def __init__(self, ru_utime, ru_stime, db_txn_count, db_txn_duration_ms, db_sched_duration_ms): - self.context = context self.ru_utime = ru_utime self.ru_stime = ru_stime self.db_txn_count = db_txn_count @@ -276,24 +275,22 @@ class _RequestStats(object): ru_utime, ru_stime = context.get_resource_usage() return _RequestStats( - context, ru_utime, ru_stime, context.db_txn_count, context.db_txn_duration_ms, context.db_sched_duration_ms, ) - def update(self): + def update(self, context): """Updates the current values and returns the difference between the old and new values. Returns: _RequestStats: The difference between the old and new values """ - new = _RequestStats.from_context(self.context) + new = _RequestStats.from_context(context) diff = _RequestStats( - self.context, new.ru_utime - self.ru_utime, new.ru_stime - self.ru_stime, new.db_txn_count - self.db_txn_count, |