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

pull/14730/head
Richard van der Hoff 2022-12-23 14:04:50 +00:00 committed by GitHub
parent 5c9be9c760
commit a52822d39c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

1
changelog.d/14724.misc Normal file
View File

@ -0,0 +1 @@
If debug logging is enabled, log the `msgid`s of any to-device messages that are returned over `/sync`.

View File

@ -37,6 +37,7 @@ from synapse.api.presence import UserPresenceState
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
from synapse.events import EventBase from synapse.events import EventBase
from synapse.handlers.relations import BundledAggregations from synapse.handlers.relations import BundledAggregations
from synapse.logging import issue9533_logger
from synapse.logging.context import current_context from synapse.logging.context import current_context
from synapse.logging.opentracing import ( from synapse.logging.opentracing import (
SynapseTags, SynapseTags,
@ -1623,12 +1624,17 @@ class SyncHandler:
} }
) )
logger.debug( if messages and issue9533_logger.isEnabledFor(logging.DEBUG):
"Returning %d to-device messages between %d and %d (current token: %d)", issue9533_logger.debug(
len(messages), "Returning to-device messages with stream_ids (%d, %d]; now: %d;"
" msgids: %s",
since_stream_id, since_stream_id,
stream_id, stream_id,
now_token.to_device_key, 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( sync_result_builder.now_token = now_token.copy_and_replace(
StreamKeyType.TO_DEVICE, stream_id StreamKeyType.TO_DEVICE, stream_id