Add Measures to presence

This commit is contained in:
Erik Johnston 2016-02-19 11:50:48 +00:00
parent 4a95eb0a12
commit 24d9f2c140

View File

@ -31,6 +31,7 @@ from synapse.storage.presence import UserPresenceState
from synapse.util.logcontext import preserve_fn from synapse.util.logcontext import preserve_fn
from synapse.util.logutils import log_function from synapse.util.logutils import log_function
from synapse.util.metrics import Measure
from synapse.util.wheel_timer import WheelTimer from synapse.util.wheel_timer import WheelTimer
from synapse.types import UserID from synapse.types import UserID
import synapse.metrics import synapse.metrics
@ -209,11 +210,14 @@ class PresenceHandler(BaseHandler):
""" """
now = self.clock.time_msec() now = self.clock.time_msec()
with Measure(self.clock, "presence_update_states"):
# NOTE: We purposefully don't yield between now and when we've # NOTE: We purposefully don't yield between now and when we've
# calculated what we want to do with the new states, to avoid races. # calculated what we want to do with the new states, to avoid races.
to_notify = {} # Changes we want to notify everyone about to_notify = {} # Changes we want to notify everyone about
to_federation_ping = {} # These need sending keep-alives to_federation_ping = {} # These need sending keep-alives
for new_state in new_states: for new_state in new_states:
user_id = new_state.user_id user_id = new_state.user_id
@ -267,6 +271,7 @@ class PresenceHandler(BaseHandler):
""" """
now = self.clock.time_msec() now = self.clock.time_msec()
with Measure(self.clock, "presence_handle_timeouts"):
# Fetch the list of users that *may* have timed out. Things may have # Fetch the list of users that *may* have timed out. Things may have
# changed since the timeout was set, so we won't necessarily have to # changed since the timeout was set, so we won't necessarily have to
# take any action. # take any action.