diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-02-01 17:57:51 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-02-05 15:34:01 +0000 |
commit | bc496df192fa20dee933590d5f21a3425388c0d7 (patch) | |
tree | fefd2b856942185a6fe114cff46ce3228872d06e /synapse/metrics | |
parent | Merge pull request #2837 from matrix-org/rav/fix_quarantine_media (diff) | |
download | synapse-bc496df192fa20dee933590d5f21a3425388c0d7.tar.xz |
report metrics on number of cache evictions
Diffstat (limited to 'synapse/metrics')
-rw-r--r-- | synapse/metrics/metric.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/synapse/metrics/metric.py b/synapse/metrics/metric.py index 1e783e5ff4..ff5aa8c0e1 100644 --- a/synapse/metrics/metric.py +++ b/synapse/metrics/metric.py @@ -193,7 +193,9 @@ class DistributionMetric(object): class CacheMetric(object): - __slots__ = ("name", "cache_name", "hits", "misses", "size_callback") + __slots__ = ( + "name", "cache_name", "hits", "misses", "evicted_size", "size_callback", + ) def __init__(self, name, size_callback, cache_name): self.name = name @@ -201,6 +203,7 @@ class CacheMetric(object): self.hits = 0 self.misses = 0 + self.evicted_size = 0 self.size_callback = size_callback @@ -210,6 +213,9 @@ class CacheMetric(object): def inc_misses(self): self.misses += 1 + def inc_evictions(self, size=1): + self.evicted_size += size + def render(self): size = self.size_callback() hits = self.hits @@ -219,6 +225,9 @@ class CacheMetric(object): """%s:hits{name="%s"} %d""" % (self.name, self.cache_name, hits), """%s:total{name="%s"} %d""" % (self.name, self.cache_name, total), """%s:size{name="%s"} %d""" % (self.name, self.cache_name, size), + """%s:evicted_size{name="%s"} %d""" % ( + self.name, self.cache_name, self.evicted_size + ), ] |