diff options
author | Paul Evans <leonerd@leonerd.org.uk> | 2015-03-13 17:31:10 +0000 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2015-03-13 17:31:10 +0000 |
commit | e731d30d90680b98237aaff7e655f26e942f468c (patch) | |
tree | f04bf166aca228c53af3a1cb2d4626f4889cbf61 /synapse/handlers/presence.py | |
parent | Also bump dependency link version (diff) | |
parent | Merge remote-tracking branch 'origin/develop' into metrics (diff) | |
download | synapse-e731d30d90680b98237aaff7e655f26e942f468c.tar.xz |
Merge pull request #108 from matrix-org/metrics
Metrics
Diffstat (limited to 'synapse/handlers/presence.py')
-rw-r--r-- | synapse/handlers/presence.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 28e922f79b..731df00648 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,11 @@ class PresenceHandler(BaseHandler): self._user_cachemap = {} self._user_cachemap_latest_serial = 0 + metrics.register_callback( + "userCachemap: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: |