summary refs log tree commit diff
path: root/synapse/util/caches/descriptors.py
diff options
context:
space:
mode:
authorRichard van der Hoff <github@rvanderhoff.org.uk>2018-02-05 16:34:36 +0100
committerGitHub <noreply@github.com>2018-02-05 16:34:36 +0100
commitdb91e72adee90f7d7bacf25f0ed517074c46e64a (patch)
treee6e8d43cd2c17bb056fb798c059d72451dd210a8 /synapse/util/caches/descriptors.py
parentFix broken unit test for media storage (diff)
parentreport metrics on number of cache evictions (diff)
downloadsynapse-db91e72adee90f7d7bacf25f0ed517074c46e64a.tar.xz
Merge pull request #2844 from matrix-org/rav/evicted_metrics
montoring metrics for number of cache evictions
Diffstat (limited to 'synapse/util/caches/descriptors.py')
-rw-r--r--synapse/util/caches/descriptors.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py
index af65bfe7b8..bf3a66eae4 100644
--- a/synapse/util/caches/descriptors.py
+++ b/synapse/util/caches/descriptors.py
@@ -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: