Improve collab logging (#2487)

This adds some logging to the collab server, to help us identify the
source of the collaboration latency we're seeing in the 0.87 preview
version of zed.
This commit is contained in:
Max Brunsfeld 2023-05-18 14:17:17 -07:00 committed by GitHub
commit 2883d6f1ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

2
Cargo.lock generated
View file

@ -1230,7 +1230,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.12.1" version = "0.12.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-tungstenite", "async-tungstenite",

View file

@ -3,7 +3,7 @@ authors = ["Nathan Sobo <nathan@zed.dev>"]
default-run = "collab" default-run = "collab"
edition = "2021" edition = "2021"
name = "collab" name = "collab"
version = "0.12.1" version = "0.12.3"
publish = false publish = false
[[bin]] [[bin]]

View file

@ -51,7 +51,7 @@ use std::{
atomic::{AtomicBool, Ordering::SeqCst}, atomic::{AtomicBool, Ordering::SeqCst},
Arc, Arc,
}, },
time::Duration, time::{Duration, Instant},
}; };
use tokio::sync::{watch, Semaphore}; use tokio::sync::{watch, Semaphore};
use tower::ServiceBuilder; use tower::ServiceBuilder;
@ -397,10 +397,16 @@ impl Server {
"message received" "message received"
); );
}); });
let start_time = Instant::now();
let future = (handler)(*envelope, session); let future = (handler)(*envelope, session);
async move { async move {
if let Err(error) = future.await { let result = future.await;
tracing::error!(%error, "error handling message"); let duration_ms = start_time.elapsed().as_micros() as f64 / 1000.0;
match result {
Err(error) => {
tracing::error!(%error, ?duration_ms, "error handling message")
}
Ok(()) => tracing::info!(?duration_ms, "finished handling message"),
} }
} }
.instrument(span) .instrument(span)