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.]
This commit is contained in:
Richard van der Hoff 2018-06-21 06:15:03 +01:00
parent aff3d76920
commit b088aafcae
3 changed files with 12 additions and 1 deletions

View file

@ -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