Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Log to-device msgids when we return them over /sync #14724

Merged
merged 1 commit into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/14724.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If debug logging is enabled, log the `msgid`s of any to-device messages that are returned over `/sync`.
20 changes: 13 additions & 7 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
from synapse.events import EventBase
from synapse.handlers.relations import BundledAggregations
from synapse.logging import issue9533_logger
from synapse.logging.context import current_context
from synapse.logging.opentracing import (
SynapseTags,
Expand Down Expand Up @@ -1623,13 +1624,18 @@ async def _generate_sync_entry_for_to_device(
}
)

logger.debug(
"Returning %d to-device messages between %d and %d (current token: %d)",
len(messages),
since_stream_id,
stream_id,
now_token.to_device_key,
)
if messages and issue9533_logger.isEnabledFor(logging.DEBUG):
issue9533_logger.debug(
"Returning to-device messages with stream_ids (%d, %d]; now: %d;"
" msgids: %s",
since_stream_id,
stream_id,
now_token.to_device_key,
[
message["content"].get(EventContentFields.TO_DEVICE_MSGID)
for message in messages
],
)
sync_result_builder.now_token = now_token.copy_and_replace(
StreamKeyType.TO_DEVICE, stream_id
)
Expand Down