Skip to content
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/18815.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Instrument the `encode_response` part of Sliding Sync requests for more complete traces in Jaeger.
11 changes: 9 additions & 2 deletions synapse/events/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
Any,
Awaitable,
Callable,
Collection,
Dict,
Iterable,
List,
Mapping,
Match,
Expand All @@ -49,6 +49,7 @@
)
from synapse.api.errors import Codes, SynapseError
from synapse.api.room_versions import RoomVersion
from synapse.logging.opentracing import SynapseTags, set_tag, trace
from synapse.types import JsonDict, Requester

from . import EventBase, StrippedStateEvent, make_event_from_dict
Expand Down Expand Up @@ -710,9 +711,10 @@ async def _inject_bundled_aggregations(
"m.relations", {}
).update(serialized_aggregations)

@trace
async def serialize_events(
self,
events: Iterable[Union[JsonDict, EventBase]],
events: Collection[Union[JsonDict, EventBase]],
time_now: int,
*,
config: SerializeEventConfig = _DEFAULT_SERIALIZE_EVENT_CONFIG,
Expand All @@ -731,6 +733,11 @@ async def serialize_events(
Returns:
The list of serialized events
"""
set_tag(
SynapseTags.FUNC_ARG_PREFIX + "events.length",
str(len(events)),
)
Comment on lines +736 to +739
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the pattern we use elsewhere

set_tag(
SynapseTags.FUNC_ARG_PREFIX + "event_ids.length",
str(len(event_ids)),
)


return [
await self.serialize_event(
event,
Expand Down
4 changes: 4 additions & 0 deletions synapse/rest/client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:

return 200, response_content

@trace_with_opname("sliding_sync.encode_response")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches what we're doing for legacy /sync

@trace_with_opname("sync.encode_response")

async def encode_response(
self,
requester: Requester,
Expand All @@ -1031,6 +1032,7 @@ async def encode_response(

return response

@trace_with_opname("sliding_sync.encode_lists")
def encode_lists(
self, lists: Mapping[str, SlidingSyncResult.SlidingWindowList]
) -> JsonDict:
Expand All @@ -1052,6 +1054,7 @@ def encode_operation(

return serialized_lists

@trace_with_opname("sliding_sync.encode_rooms")
async def encode_rooms(
self,
requester: Requester,
Expand Down Expand Up @@ -1172,6 +1175,7 @@ async def encode_rooms(

return serialized_rooms

@trace_with_opname("sliding_sync.encode_extensions")
async def encode_extensions(
self, requester: Requester, extensions: SlidingSyncResult.Extensions
) -> JsonDict:
Expand Down
Loading