mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 02:54:52 -04:00
report metrics on number of cache evictions
This commit is contained in:
parent
77c0629ebc
commit
bc496df192
5 changed files with 56 additions and 5 deletions
|
@ -75,6 +75,7 @@ class Cache(object):
|
|||
self.cache = LruCache(
|
||||
max_size=max_entries, keylen=keylen, cache_type=cache_type,
|
||||
size_callback=(lambda d: len(d)) if iterable else None,
|
||||
evicted_callback=self._on_evicted,
|
||||
)
|
||||
|
||||
self.name = name
|
||||
|
@ -83,6 +84,9 @@ class Cache(object):
|
|||
self.thread = None
|
||||
self.metrics = register_cache(name, self.cache)
|
||||
|
||||
def _on_evicted(self, evicted_count):
|
||||
self.metrics.inc_evictions(evicted_count)
|
||||
|
||||
def check_thread(self):
|
||||
expected_thread = self.thread
|
||||
if expected_thread is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue