diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2018-02-05 16:34:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-05 16:34:36 +0100 |
commit | db91e72adee90f7d7bacf25f0ed517074c46e64a (patch) | |
tree | e6e8d43cd2c17bb056fb798c059d72451dd210a8 /synapse/util/caches/expiringcache.py | |
parent | Fix broken unit test for media storage (diff) | |
parent | report metrics on number of cache evictions (diff) | |
download | synapse-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/expiringcache.py')
-rw-r--r-- | synapse/util/caches/expiringcache.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/util/caches/expiringcache.py b/synapse/util/caches/expiringcache.py index 6ad53a6390..0aa103eecb 100644 --- a/synapse/util/caches/expiringcache.py +++ b/synapse/util/caches/expiringcache.py @@ -79,7 +79,11 @@ class ExpiringCache(object): while self._max_len and len(self) > self._max_len: _key, value = self._cache.popitem(last=False) if self.iterable: - self._size_estimate -= len(value.value) + removed_len = len(value.value) + self.metrics.inc_evictions(removed_len) + self._size_estimate -= removed_len + else: + self.metrics.inc_evictions() def __getitem__(self, key): try: |