Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove old CPU/Memory events (#20865)
Conrad Irwin496dae968b8f
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex bed52955ad2..ee6f81dd84f 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -353,7 +353,6 @@ jobs:files: |target/zed-remote-server-linux-x86_64.gztarget/release/zed-linux-x86_64.tar.gz- body: ""env:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}@@ -400,6 +399,21 @@ jobs:files: |target/zed-remote-server-linux-aarch64.gztarget/release/zed-linux-aarch64.tar.gz- body: ""+ env:+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}++ auto-publish-release:+ timeout-minutes: 60+ name: Create a Linux bundle+ runs-on:+ - self-hosted+ if: ${{ startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre') }}+ needs: [bundle-mac, bundle-linux-aarch64, bundle-linux]+ steps:+ - name: Upload app bundle to release+ uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1+ with:+ draft: false+ prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}env:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}diff --git a/Cargo.lock b/Cargo.lockindex 38de2f5c001..527190bacae 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2456,7 +2456,6 @@ dependencies = ["settings","sha2","smol",- "sysinfo","telemetry_events","text","thiserror 1.0.69",diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.tomlindex 98920112972..23716f0c69d 100644--- a/crates/client/Cargo.toml+++ b/crates/client/Cargo.toml@@ -42,7 +42,6 @@ serde_json.workspace = truesettings.workspace = truesha2.workspace = truesmol.workspace = true-sysinfo.workspace = truetelemetry_events.workspace = truetext.workspace = truethiserror.workspace = truediff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rsindex b472cf768eb..fcb9ced4e57 100644--- a/crates/client/src/telemetry.rs+++ b/crates/client/src/telemetry.rs@@ -16,11 +16,9 @@ use std::fs::File;use std::io::Write;use std::time::Instant;use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};-use sysinfo::{CpuRefreshKind, Pid, ProcessRefreshKind, RefreshKind, System};use telemetry_events::{- ActionEvent, AppEvent, AssistantEvent, CallEvent, CpuEvent, EditEvent, EditorEvent, Event,- EventRequestBody, EventWrapper, ExtensionEvent, InlineCompletionEvent, MemoryEvent, ReplEvent,- SettingEvent,+ ActionEvent, AppEvent, AssistantEvent, CallEvent, EditEvent, EditorEvent, Event,+ EventRequestBody, EventWrapper, ExtensionEvent, InlineCompletionEvent, ReplEvent, SettingEvent,};use util::{ResultExt, TryFutureExt};use worktree::{UpdatedEntriesSet, WorktreeId};@@ -293,48 +291,6 @@ impl Telemetry {state.session_id = Some(session_id);state.app_version = release_channel::AppVersion::global(cx).to_string();state.os_name = os_name();-- drop(state);-- let this = self.clone();- cx.background_executor()- .spawn(async move {- let mut system = System::new_with_specifics(- RefreshKind::new().with_cpu(CpuRefreshKind::everything()),- );-- let refresh_kind = ProcessRefreshKind::new().with_cpu().with_memory();- let current_process = Pid::from_u32(std::process::id());- system.refresh_processes_specifics(- sysinfo::ProcessesToUpdate::Some(&[current_process]),- refresh_kind,- );-- // Waiting some amount of time before the first query is important to get a reasonable value- // https://docs.rs/sysinfo/0.29.10/sysinfo/trait.ProcessExt.html#tymethod.cpu_usage- const DURATION_BETWEEN_SYSTEM_EVENTS: Duration = Duration::from_secs(4 * 60);-- loop {- smol::Timer::after(DURATION_BETWEEN_SYSTEM_EVENTS).await;-- let current_process = Pid::from_u32(std::process::id());- system.refresh_processes_specifics(- sysinfo::ProcessesToUpdate::Some(&[current_process]),- refresh_kind,- );- let Some(process) = system.process(current_process) else {- log::error!(- "Failed to find own process {current_process:?} in system process table"- );- // TODO: Fire an error telemetry event- return;- };-- this.report_memory_event(process.memory(), process.virtual_memory());- this.report_cpu_event(process.cpu_usage(), system.cpus().len() as u32);- }- })- .detach();}pub fn metrics_enabled(self: &Arc<Self>) -> bool {@@ -416,28 +372,6 @@ impl Telemetry {self.report_event(event)}- pub fn report_cpu_event(self: &Arc<Self>, usage_as_percentage: f32, core_count: u32) {- let event = Event::Cpu(CpuEvent {- usage_as_percentage,- core_count,- });-- self.report_event(event)- }-- pub fn report_memory_event(- self: &Arc<Self>,- memory_in_bytes: u64,- virtual_memory_in_bytes: u64,- ) {- let event = Event::Memory(MemoryEvent {- memory_in_bytes,- virtual_memory_in_bytes,- });-- self.report_event(event)- }-pub fn report_app_event(self: &Arc<Self>, operation: String) -> Event {let event = Event::App(AppEvent { operation });diff --git a/crates/collab/src/api/events.rs b/crates/collab/src/api/events.rsindex 053657a8d11..80f477df300 100644--- a/crates/collab/src/api/events.rs+++ b/crates/collab/src/api/events.rs@@ -483,20 +483,7 @@ pub async fn post_events(checksum_matched,))}- Event::Cpu(event) => to_upload.cpu_events.push(CpuEventRow::from_event(- event.clone(),- wrapper,- &request_body,- first_event_at,- checksum_matched,- )),- Event::Memory(event) => to_upload.memory_events.push(MemoryEventRow::from_event(- event.clone(),- wrapper,- &request_body,- first_event_at,- checksum_matched,- )),+ Event::Cpu(_) | Event::Memory(_) => continue,Event::App(event) => to_upload.app_events.push(AppEventRow::from_event(event.clone(),wrapper,@@ -947,6 +934,7 @@ pub struct CpuEventRow {}impl CpuEventRow {+ #[allow(unused)]fn from_event(event: CpuEvent,wrapper: &EventWrapper,@@ -1001,6 +989,7 @@ pub struct MemoryEventRow {}impl MemoryEventRow {+ #[allow(unused)]fn from_event(event: MemoryEvent,wrapper: &EventWrapper,@@ -1393,7 +1382,7 @@ fn for_snowflake(body: EventRequestBody,first_event_at: chrono::DateTime<chrono::Utc>,) -> impl Iterator<Item = SnowflakeRow> {- body.events.into_iter().map(move |event| {+ body.events.into_iter().flat_map(move |event| {let timestamp =first_event_at + Duration::milliseconds(event.milliseconds_since_first_event);let (event_type, mut event_properties) = match &event.event {@@ -1450,14 +1439,7 @@ fn for_snowflake(},serde_json::to_value(e).unwrap(),),- Event::Cpu(e) => (- "System CPU Sampled".to_string(),- serde_json::to_value(e).unwrap(),- ),- Event::Memory(e) => (- "System Memory Sampled".to_string(),- serde_json::to_value(e).unwrap(),- ),+ Event::Cpu(_) | Event::Memory(_) => return None,Event::App(e) => {let mut properties = json!({});let event_type = match e.operation.trim() {@@ -1577,7 +1559,7 @@ fn for_snowflake("is_staff": body.is_staff,}));- SnowflakeRow {+ Some(SnowflakeRow {time: timestamp,user_id: body.metrics_id.clone(),device_id: body.system_id.clone(),@@ -1585,7 +1567,7 @@ fn for_snowflake(event_properties,user_properties,insert_id: Some(Uuid::new_v4().to_string()),- }+ })})}