Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

ep: LSP telemetry (#58925)

Ben Kunkle9fe16436405c
diff --git a/Cargo.lock b/Cargo.lock
index 9fb85c94da1..829bb12da64 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5595,6 +5595,7 @@ dependencies = [
"serde_json",
"settings",
"smallvec",
+ "telemetry",
"text",
"tree-sitter",
"util",
diff --git a/crates/edit_prediction_context/Cargo.toml b/crates/edit_prediction_context/Cargo.toml
index 3a63f16610a..244b5f736e5 100644
--- a/crates/edit_prediction_context/Cargo.toml
+++ b/crates/edit_prediction_context/Cargo.toml
@@ -24,6 +24,7 @@ parking_lot.workspace = true
project.workspace = true
serde.workspace = true
smallvec.workspace = true
+telemetry.workspace = true
text.workspace = true
tree-sitter.workspace = true
util.workspace = true
diff --git a/crates/edit_prediction_context/src/edit_prediction_context.rs b/crates/edit_prediction_context/src/edit_prediction_context.rs
index 0bcd63cdcf0..44e295908af 100644
--- a/crates/edit_prediction_context/src/edit_prediction_context.rs
+++ b/crates/edit_prediction_context/src/edit_prediction_context.rs
@@ -228,9 +228,25 @@ impl RelatedExcerptStore {
};
let file = snapshot.file().cloned();
+ let file_extension = file
+ .as_ref()
+ .and_then(|file| file.path().extension())
+ .unwrap_or("")
+ .to_string();
if let Some(file) = &file {
log::debug!("retrieving_context buffer:{}", file.path().as_unix_str());
}
+ let (lsp_store, is_via_ssh) = project.read_with(cx, |project, _| {
+ (project.lsp_store(), project.is_via_remote_server())
+ });
+ let lsp_names = lsp_store.update(cx, |lsp_store, cx| {
+ buffer.update(cx, |buffer, cx| {
+ lsp_store
+ .running_language_servers_for_local_buffer(buffer, cx)
+ .map(|(_, server)| server.name().to_string())
+ .collect::<Vec<_>>()
+ })
+ });
this.update(cx, |_, cx| {
cx.emit(RelatedExcerptStoreEvent::StartedRefresh);
@@ -400,10 +416,25 @@ impl RelatedExcerptStore {
cache_hit_count += 1;
}
}
+ let lsp_fetch_latency_ms = start_time.elapsed().as_millis();
mean_definition_latency /= cache_miss_count.max(1) as u32;
let (new_cache, related_buffers) =
rebuild_related_files(&project, new_cache, &cursor_distances, cx).await?;
+ let latency_ms = start_time.elapsed().as_millis();
+ let returned_excerpt_count = related_buffers
+ .iter()
+ .map(|related_buffer| related_buffer.anchor_ranges.len())
+ .sum::<usize>();
+ telemetry::event!(
+ "Edit Prediction LSP Context Retrieved",
+ lsp_names,
+ file_extension,
+ latency_ms,
+ lsp_fetch_latency_ms,
+ returned_excerpt_count,
+ is_via_ssh
+ );
if let Some(file) = &file {
log::debug!(