mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-16 15:01:23 +01:00
Add some tracing spans to give insight into local joins (#13439)
This commit is contained in:
parent
92d21faf12
commit
a648a06d52
3 changed files with 40 additions and 33 deletions
1
changelog.d/13439.misc
Normal file
1
changelog.d/13439.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Add some tracing to give more insight into local room joins.
|
|
@ -52,6 +52,7 @@ from synapse.events.builder import EventBuilder
|
||||||
from synapse.events.snapshot import EventContext
|
from synapse.events.snapshot import EventContext
|
||||||
from synapse.events.validator import EventValidator
|
from synapse.events.validator import EventValidator
|
||||||
from synapse.handlers.directory import DirectoryHandler
|
from synapse.handlers.directory import DirectoryHandler
|
||||||
|
from synapse.logging import opentracing
|
||||||
from synapse.logging.context import make_deferred_yieldable, run_in_background
|
from synapse.logging.context import make_deferred_yieldable, run_in_background
|
||||||
from synapse.metrics.background_process_metrics import run_as_background_process
|
from synapse.metrics.background_process_metrics import run_as_background_process
|
||||||
from synapse.replication.http.send_event import ReplicationSendEventRestServlet
|
from synapse.replication.http.send_event import ReplicationSendEventRestServlet
|
||||||
|
@ -1374,9 +1375,10 @@ class EventCreationHandler:
|
||||||
# and `state_groups` because they have `prev_events` that aren't persisted yet
|
# and `state_groups` because they have `prev_events` that aren't persisted yet
|
||||||
# (historical messages persisted in reverse-chronological order).
|
# (historical messages persisted in reverse-chronological order).
|
||||||
if not event.internal_metadata.is_historical():
|
if not event.internal_metadata.is_historical():
|
||||||
await self._bulk_push_rule_evaluator.action_for_event_by_user(
|
with opentracing.start_active_span("calculate_push_actions"):
|
||||||
event, context
|
await self._bulk_push_rule_evaluator.action_for_event_by_user(
|
||||||
)
|
event, context
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# If we're a worker we need to hit out to the master.
|
# If we're a worker we need to hit out to the master.
|
||||||
|
@ -1463,9 +1465,10 @@ class EventCreationHandler:
|
||||||
state = await state_entry.get_state(
|
state = await state_entry.get_state(
|
||||||
self._storage_controllers.state, StateFilter.all()
|
self._storage_controllers.state, StateFilter.all()
|
||||||
)
|
)
|
||||||
joined_hosts = await self.store.get_joined_hosts(
|
with opentracing.start_active_span("get_joined_hosts"):
|
||||||
event.room_id, state, state_entry
|
joined_hosts = await self.store.get_joined_hosts(
|
||||||
)
|
event.room_id, state, state_entry
|
||||||
|
)
|
||||||
|
|
||||||
# Note that the expiry times must be larger than the expiry time in
|
# Note that the expiry times must be larger than the expiry time in
|
||||||
# _external_cache_joined_hosts_updates.
|
# _external_cache_joined_hosts_updates.
|
||||||
|
|
|
@ -32,6 +32,7 @@ from synapse.event_auth import get_named_level, get_power_level_event
|
||||||
from synapse.events import EventBase
|
from synapse.events import EventBase
|
||||||
from synapse.events.snapshot import EventContext
|
from synapse.events.snapshot import EventContext
|
||||||
from synapse.handlers.profile import MAX_AVATAR_URL_LEN, MAX_DISPLAYNAME_LEN
|
from synapse.handlers.profile import MAX_AVATAR_URL_LEN, MAX_DISPLAYNAME_LEN
|
||||||
|
from synapse.logging import opentracing
|
||||||
from synapse.module_api import NOT_SPAM
|
from synapse.module_api import NOT_SPAM
|
||||||
from synapse.storage.state import StateFilter
|
from synapse.storage.state import StateFilter
|
||||||
from synapse.types import (
|
from synapse.types import (
|
||||||
|
@ -428,14 +429,14 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
|
||||||
await self._join_rate_per_room_limiter.ratelimit(
|
await self._join_rate_per_room_limiter.ratelimit(
|
||||||
requester, key=room_id, update=False
|
requester, key=room_id, update=False
|
||||||
)
|
)
|
||||||
|
with opentracing.start_active_span("handle_new_client_event"):
|
||||||
result_event = await self.event_creation_handler.handle_new_client_event(
|
result_event = await self.event_creation_handler.handle_new_client_event(
|
||||||
requester,
|
requester,
|
||||||
event,
|
event,
|
||||||
context,
|
context,
|
||||||
extra_users=[target],
|
extra_users=[target],
|
||||||
ratelimit=ratelimit,
|
ratelimit=ratelimit,
|
||||||
)
|
)
|
||||||
|
|
||||||
if event.membership == Membership.LEAVE:
|
if event.membership == Membership.LEAVE:
|
||||||
if prev_member_event_id:
|
if prev_member_event_id:
|
||||||
|
@ -564,25 +565,26 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
|
||||||
# by application services), and then by room ID.
|
# by application services), and then by room ID.
|
||||||
async with self.member_as_limiter.queue(as_id):
|
async with self.member_as_limiter.queue(as_id):
|
||||||
async with self.member_linearizer.queue(key):
|
async with self.member_linearizer.queue(key):
|
||||||
result = await self.update_membership_locked(
|
with opentracing.start_active_span("update_membership_locked"):
|
||||||
requester,
|
result = await self.update_membership_locked(
|
||||||
target,
|
requester,
|
||||||
room_id,
|
target,
|
||||||
action,
|
room_id,
|
||||||
txn_id=txn_id,
|
action,
|
||||||
remote_room_hosts=remote_room_hosts,
|
txn_id=txn_id,
|
||||||
third_party_signed=third_party_signed,
|
remote_room_hosts=remote_room_hosts,
|
||||||
ratelimit=ratelimit,
|
third_party_signed=third_party_signed,
|
||||||
content=content,
|
ratelimit=ratelimit,
|
||||||
new_room=new_room,
|
content=content,
|
||||||
require_consent=require_consent,
|
new_room=new_room,
|
||||||
outlier=outlier,
|
require_consent=require_consent,
|
||||||
historical=historical,
|
outlier=outlier,
|
||||||
allow_no_prev_events=allow_no_prev_events,
|
historical=historical,
|
||||||
prev_event_ids=prev_event_ids,
|
allow_no_prev_events=allow_no_prev_events,
|
||||||
state_event_ids=state_event_ids,
|
prev_event_ids=prev_event_ids,
|
||||||
depth=depth,
|
state_event_ids=state_event_ids,
|
||||||
)
|
depth=depth,
|
||||||
|
)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -649,6 +651,7 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
|
||||||
Returns:
|
Returns:
|
||||||
A tuple of the new event ID and stream ID.
|
A tuple of the new event ID and stream ID.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
content_specified = bool(content)
|
content_specified = bool(content)
|
||||||
if content is None:
|
if content is None:
|
||||||
content = {}
|
content = {}
|
||||||
|
|
Loading…
Reference in a new issue