Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(timeline): instrument timeline tasks with their focus and internal id prefix #4138

Merged
merged 1 commit into from
Oct 16, 2024
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
19 changes: 15 additions & 4 deletions crates/matrix-sdk-ui/src/timeline/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl TimelineBuilder {
let controller = TimelineController::new(
room,
focus.clone(),
internal_id_prefix,
internal_id_prefix.clone(),
unable_to_decrypt_hook,
is_room_encrypted,
)
Expand Down Expand Up @@ -206,8 +206,13 @@ impl TimelineBuilder {
let room_event_cache = room_event_cache.clone();
let inner = controller.clone();

let span =
info_span!(parent: Span::none(), "room_update_handler", room_id = ?room.room_id());
let span = info_span!(
parent: Span::none(),
"live_update_handler",
room_id = ?room.room_id(),
focus = focus.debug_string(),
prefix = internal_id_prefix
);
span.follows_from(Span::current());

async move {
Expand Down Expand Up @@ -307,7 +312,13 @@ impl TimelineBuilder {
timeline.handle_local_echo(echo).await;
}

let span = info_span!(parent: Span::none(), "local_echo_handler", room_id = ?room.room_id());
let span = info_span!(
parent: Span::none(),
"local_echo_handler",
room_id = ?room.room_id(),
focus = focus.debug_string(),
prefix = internal_id_prefix
);
span.follows_from(Span::current());

// React to future local echoes too.
Expand Down
10 changes: 10 additions & 0 deletions crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ pub enum TimelineFocus {
PinnedEvents { max_events_to_load: u16, max_concurrent_requests: u16 },
}

impl TimelineFocus {
pub(super) fn debug_string(&self) -> String {
match self {
TimelineFocus::Live => "live".to_owned(),
TimelineFocus::Event { target, .. } => format!("permalink:{target}"),
TimelineFocus::PinnedEvents { .. } => "pinned-events".to_owned(),
}
}
}

impl Timeline {
/// Create a new [`TimelineBuilder`] for the given room.
pub fn builder(room: &Room) -> TimelineBuilder {
Expand Down
8 changes: 7 additions & 1 deletion crates/matrix-sdk-ui/tests/integration/timeline/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ async fn test_echo() {
mock_encryption_state(&server, false).await;

let room = client.get_room(room_id).unwrap();
let timeline = Arc::new(room.timeline().await.unwrap());
let timeline = Arc::new(
room.timeline_builder()
.with_internal_id_prefix("le_prefix".to_owned())
.build()
.await
.unwrap(),
);
let (_, mut timeline_stream) = timeline.subscribe().await;

Mock::given(method("PUT"))
Expand Down
Loading