Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
zeta: Add latency telemetry for 1% of edit predictions (#36020)
Michael Sloancc5eb2406691
diff --git a/Cargo.lock b/Cargo.lockindex 8d22eeafab5..79bce189e2e 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -20923,6 +20923,7 @@ dependencies = ["menu","postage","project",+ "rand 0.8.5","regex","release_channel","reqwest_client",diff --git a/crates/zeta/Cargo.toml b/crates/zeta/Cargo.tomlindex 9f1d02b7900..ee76308ff38 100644--- a/crates/zeta/Cargo.toml+++ b/crates/zeta/Cargo.toml@@ -26,6 +26,7 @@ collections.workspace = truecommand_palette_hooks.workspace = truecopilot.workspace = truedb.workspace = true+edit_prediction.workspace = trueeditor.workspace = truefeature_flags.workspace = truefs.workspace = true@@ -33,13 +34,13 @@ futures.workspace = truegpui.workspace = truehttp_client.workspace = trueindoc.workspace = true-edit_prediction.workspace = truelanguage.workspace = truelanguage_model.workspace = truelog.workspace = truemenu.workspace = truepostage.workspace = trueproject.workspace = true+rand.workspace = trueregex.workspace = truerelease_channel.workspace = trueserde.workspace = truediff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rsindex 69000820035..1a6a8c29348 100644--- a/crates/zeta/src/zeta.rs+++ b/crates/zeta/src/zeta.rs@@ -429,6 +429,7 @@ impl Zeta {body,editable_range,} = gather_task.await?;+ let done_gathering_context_at = Instant::now();log::debug!("Events:\n{}\nExcerpt:\n{:?}",@@ -481,6 +482,7 @@ impl Zeta {}};+ let received_response_at = Instant::now();log::debug!("completion response: {}", &response.output_excerpt);if let Some(usage) = usage {@@ -492,7 +494,7 @@ impl Zeta {.ok();}- Self::process_completion_response(+ let edit_prediction = Self::process_completion_response(response,buffer,&snapshot,@@ -505,7 +507,25 @@ impl Zeta {buffer_snapshotted_at,&cx,)- .await+ .await;++ let finished_at = Instant::now();++ // record latency for ~1% of requests+ if rand::random::<u8>() <= 2 {+ telemetry::event!(+ "Edit Prediction Request",+ context_latency = done_gathering_context_at+ .duration_since(buffer_snapshotted_at)+ .as_millis(),+ request_latency = received_response_at+ .duration_since(done_gathering_context_at)+ .as_millis(),+ process_latency = finished_at.duration_since(received_response_at).as_millis()+ );+ }++ edit_prediction})}