From 0b2a9480f10487cacf191fa7294ecf4a5a632ab2 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Tue, 9 Jun 2026 11:52:27 -0400 Subject: [PATCH] ep: LSP telemetry (#58925) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - N/A or Added/Fixed/Improved ... --- Cargo.lock | 1 + crates/edit_prediction_context/Cargo.toml | 1 + .../src/edit_prediction_context.rs | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 9fb85c94da..829bb12da6 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 3a63f16610..244b5f736e 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 0bcd63cdcf..44e295908a 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::>() + }) + }); 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::(); + 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!(