summary refs log tree commit diff
path: root/synapse/storage/receipts.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-08-13 16:58:23 +0100
committerErik Johnston <erik@matrix.org>2015-08-13 16:58:23 +0100
commit5db56779699a3c9a95701e6373ac8bd5cace7860 (patch)
treed26a26569ec3f45931c68f22e99f3fc1bb38892f /synapse/storage/receipts.py
parentRe-enable receipts (diff)
downloadsynapse-5db56779699a3c9a95701e6373ac8bd5cace7860.tar.xz
Add metrics to the receipts cache
Diffstat (limited to 'synapse/storage/receipts.py')
-rw-r--r--synapse/storage/receipts.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/synapse/storage/receipts.py b/synapse/storage/receipts.py
index cac1a5657e..42f4b5f78d 100644
--- a/synapse/storage/receipts.py
+++ b/synapse/storage/receipts.py
@@ -15,6 +15,7 @@
 
 from ._base import SQLBaseStore
 from synapse.util.caches.descriptors import cachedInlineCallbacks
+from synapse.util.caches import cache_counter, caches_by_name
 
 from twisted.internet import defer
 
@@ -305,6 +306,8 @@ class _RoomStreamChangeCache(object):
         self._room_to_key = {}
         self._cache = sorteddict()
         self._earliest_key = None
+        self.name = "ReceiptsRoomChangeCache"
+        caches_by_name[self.name] = self._cache
 
     @defer.inlineCallbacks
     def get_rooms_changed(self, store, room_ids, key):
@@ -321,6 +324,9 @@ class _RoomStreamChangeCache(object):
         else:
             result = room_ids
 
+        cache_counter.inc_hits_by(len(result), self.name)
+        cache_counter.inc_misses_by(len(room_ids) - len(result), self.name)
+
         defer.returnValue(result)
 
     @defer.inlineCallbacks