summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-06-21 06:15:03 +0100
committerRichard van der Hoff <richard@matrix.org>2018-06-21 06:15:03 +0100
commitb088aafcae71fa61433f92ce0b139802a9cbd304 (patch)
treec3f8063a1a10ce58f78c0f457bd65e394838ffe5 /synapse/util
parentMerge pull request #3416 from matrix-org/rav/restart_indicator (diff)
downloadsynapse-b088aafcae71fa61433f92ce0b139802a9cbd304.tar.xz
Log number of events fetched from DB
When we finish processing a request, log the number of events we fetched from
the database to handle it.

[I'm trying to figure out which requests are responsible for large amounts of
event cache churn. It may turn out to be more helpful to add counts to the
prometheus per-request/block metrics, but that is an extension to this code
anyway.]
Diffstat (limited to 'synapse/util')
-rw-r--r--synapse/util/logcontext.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/synapse/util/logcontext.py b/synapse/util/logcontext.py
index a58c723403..2bfd4bee96 100644
--- a/synapse/util/logcontext.py
+++ b/synapse/util/logcontext.py
@@ -60,6 +60,7 @@ class LoggingContext(object):
     __slots__ = [
         "previous_context", "name", "ru_stime", "ru_utime",
         "db_txn_count", "db_txn_duration_sec", "db_sched_duration_sec",
+        "evt_db_fetch_count",
         "usage_start",
         "main_thread", "alive",
         "request", "tag",
@@ -109,6 +110,9 @@ class LoggingContext(object):
         # sec spent waiting for db txns to be scheduled
         self.db_sched_duration_sec = 0
 
+        # number of events this thread has fetched from the db
+        self.evt_db_fetch_count = 0
+
         # If alive has the thread resource usage when the logcontext last
         # became active.
         self.usage_start = None