Cleanup opentracing logging for syncs (#10828)

We added a bunch of spans in #10704, but this ended up adding a lot of
redundant spans for rooms where nothing changed, so instead we only
start the span if there might be something interesting going on.
This commit is contained in:
Erik Johnston 2021-09-15 17:14:25 +01:00 committed by GitHub
parent 474edce1c4
commit 9a6f4a684f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 155 additions and 139 deletions

1
changelog.d/10828.bugfix Normal file
View file

@ -0,0 +1 @@
Added opentrace logging to help debug #9424.

View file

@ -1533,9 +1533,6 @@ class SyncHandler:
newly_left_rooms = room_changes.newly_left_rooms
async def handle_room_entries(room_entry: "RoomSyncResultBuilder"):
with start_active_span("generate_room_entry"):
set_tag("room_id", room_entry.room_id)
log_kv({"events": len(room_entry.events or [])})
logger.debug("Generating room entry for %s", room_entry.room_id)
res = await self._generate_room_entry(
sync_result_builder,
@ -1960,6 +1957,11 @@ class SyncHandler:
room_id = room_builder.room_id
since_token = room_builder.since_token
upto_token = room_builder.upto_token
with start_active_span("generate_room_entry"):
set_tag("room_id", room_id)
log_kv({"events": len(events or ())})
log_kv(
{
"since_token": since_token,
@ -2013,21 +2015,34 @@ class SyncHandler:
account_data_events.append({"type": "m.tag", "content": {"tags": tags}})
for account_data_type, content in account_data.items():
account_data_events.append({"type": account_data_type, "content": content})
account_data_events.append(
{"type": account_data_type, "content": content}
)
account_data_events = sync_config.filter_collection.filter_room_account_data(
account_data_events = (
sync_config.filter_collection.filter_room_account_data(
account_data_events
)
)
ephemeral = sync_config.filter_collection.filter_room_ephemeral(ephemeral)
if not (
always_include or batch or account_data_events or ephemeral or full_state
always_include
or batch
or account_data_events
or ephemeral
or full_state
):
return
state = await self.compute_state_delta(
room_id, batch, sync_config, since_token, now_token, full_state=full_state
room_id,
batch,
sync_config,
since_token,
now_token,
full_state=full_state,
)
summary: Optional[JsonDict] = {}