Add a scalar gauge metric on the size of the presence user cachemap
This commit is contained in:
parent
d8caa5454d
commit
59c448f074
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue