summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2022-07-17 16:29:26 +0100
committerErik Johnston <erik@matrix.org>2022-07-17 16:29:26 +0100
commit6b64fde67449843b6b0fdb8a608c884eacaf429f (patch)
tree5544466f63a2d181830a62caaa5e6b63301c9d49
parentAdd doorkeeper (diff)
downloadsynapse-6b64fde67449843b6b0fdb8a608c884eacaf429f.tar.xz
Doorkeeper metrics
-rw-r--r--synapse/util/caches/lrucache.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/synapse/util/caches/lrucache.py b/synapse/util/caches/lrucache.py
index c640c238d5..af38b1c1f5 100644
--- a/synapse/util/caches/lrucache.py
+++ b/synapse/util/caches/lrucache.py
@@ -35,6 +35,7 @@ from typing import (
 )
 
 from cuckoo.filter import ScalableCuckooFilter
+from prometheus_client import Counter
 from typing_extensions import Literal
 
 from twisted.internet import reactor
@@ -53,6 +54,9 @@ if TYPE_CHECKING:
 
 logger = logging.getLogger(__name__)
 
+doorkeeper_counter = Counter("synapse_lru_cache_doorkeeper_total", "")
+doorkeeper_hit_counter = Counter("synapse_lru_cache_doorkeeper_hits", "")
+
 try:
     from pympler.asizeof import Asizer
 
@@ -509,6 +513,7 @@ class LruCache(Generic[KT, VT]):
             key: KT, value: VT, callbacks: Collection[Callable[[], None]] = ()
         ) -> None:
             hash_key = hash(()).to_bytes(8, byteorder="big")
+            doorkeeper_counter.inc()
             found = self._doorkeeper.contains(hash_key) | self._doorkeeper_2.contains(
                 hash_key
             )
@@ -516,6 +521,8 @@ class LruCache(Generic[KT, VT]):
                 self._doorkeeper.insert(hash_key)
                 return
 
+            doorkeeper_hit_counter.inc()
+
             node: _Node[KT, VT] = _Node(
                 list_root,
                 key,