diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-04 16:50:23 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-12 16:24:50 +0000 |
commit | 59c448f074439f1c6f5f51765e24ecfcff8e4101 (patch) | |
tree | 3dc781ff3ac3198e866144da94b5c592868122eb | |
parent | Initial attempt at a scalar callback-based metric to give instantaneous snaps... (diff) | |
download | synapse-59c448f074439f1c6f5f51765e24ecfcff8e4101.tar.xz |
Add a scalar gauge metric on the size of the presence user cachemap
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/presence.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 28e922f79b..698946a48b 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -21,6 +21,7 @@ from synapse.api.constants import PresenceState from synapse.util.logutils import log_function from synapse.util.logcontext import PreserveLoggingContext from synapse.types import UserID +import synapse.metrics from ._base import BaseHandler @@ -29,6 +30,8 @@ import logging logger = logging.getLogger(__name__) +metrics = synapse.metrics.get_metrics_for(__name__) + # TODO(paul): Maybe there's one of these I can steal from somewhere def partition(l, func): @@ -133,6 +136,10 @@ class PresenceHandler(BaseHandler): self._user_cachemap = {} self._user_cachemap_latest_serial = 0 + metrics.register_callback("user_cachemap:size", + lambda: len(self._user_cachemap) + ) + def _get_or_make_usercache(self, user): """If the cache entry doesn't exist, initialise a new one.""" if user not in self._user_cachemap: |