Skip to content
Snippets Groups Projects
Unverified Commit a03d71dc authored by Erik Johnston's avatar Erik Johnston Committed by GitHub
Browse files

Fix "Starting metrics collection from sentinel context" errors (#9053)

parent 12f79da5
No related branches found
No related tags found
No related merge requests found
Fix bug where we didn't correctly record CPU time spent in 'on_new_event' block.
...@@ -396,31 +396,30 @@ class Notifier: ...@@ -396,31 +396,30 @@ class Notifier:
Will wake up all listeners for the given users and rooms. Will wake up all listeners for the given users and rooms.
""" """
with PreserveLoggingContext(): with Measure(self.clock, "on_new_event"):
with Measure(self.clock, "on_new_event"): user_streams = set()
user_streams = set()
for user in users: for user in users:
user_stream = self.user_to_user_stream.get(str(user)) user_stream = self.user_to_user_stream.get(str(user))
if user_stream is not None: if user_stream is not None:
user_streams.add(user_stream) user_streams.add(user_stream)
for room in rooms: for room in rooms:
user_streams |= self.room_to_user_streams.get(room, set()) user_streams |= self.room_to_user_streams.get(room, set())
time_now_ms = self.clock.time_msec() time_now_ms = self.clock.time_msec()
for user_stream in user_streams: for user_stream in user_streams:
try: try:
user_stream.notify(stream_key, new_token, time_now_ms) user_stream.notify(stream_key, new_token, time_now_ms)
except Exception: except Exception:
logger.exception("Failed to notify listener") logger.exception("Failed to notify listener")
self.notify_replication() self.notify_replication()
# Notify appservices # Notify appservices
self._notify_app_services_ephemeral( self._notify_app_services_ephemeral(
stream_key, new_token, users, stream_key, new_token, users,
) )
def on_new_replication_data(self) -> None: def on_new_replication_data(self) -> None:
"""Used to inform replication listeners that something has happened """Used to inform replication listeners that something has happened
......
...@@ -111,7 +111,8 @@ class Measure: ...@@ -111,7 +111,8 @@ class Measure:
curr_context = current_context() curr_context = current_context()
if not curr_context: if not curr_context:
logger.warning( logger.warning(
"Starting metrics collection from sentinel context: metrics will be lost" "Starting metrics collection %r from sentinel context: metrics will be lost",
name,
) )
parent_context = None parent_context = None
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment