Skip to content

Commit a809833

Browse files
yangdanny97meta-codesync[bot]
authored andcommitted
track time since server started in telemetry
Summary: that way we can discern whether long-running events happened during initial indexing or later Reviewed By: stroxler Differential Revision: D95564306 fbshipit-source-id: 300c234806481b673400874385a4014863a1a64e
1 parent 10c1f84 commit a809833

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

crates/pyrefly_util/src/telemetry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub struct TelemetryServerState {
106106
pub id: Uuid,
107107
/// The surface/entrypoint for the language server
108108
pub surface: Option<String>,
109+
pub server_start_time: Instant,
109110
}
110111

111112
#[derive(Default)]

pyrefly/lib/lsp/non_wasm/server.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,8 @@ pub struct Server {
801801
/// An external source which may be included to assist in finding global references
802802
#[expect(dead_code)]
803803
external_references: Arc<dyn ExternalReferences>,
804+
/// The time at which the server was started, for telemetry.
805+
server_start_time: Instant,
804806
}
805807

806808
pub fn shutdown_finish(sender: &Sender<Message>, reader: &mut MessageReader, id: RequestId) {
@@ -2285,6 +2287,7 @@ impl Server {
22852287
path_remapper,
22862288
pending_watched_file_changes: Mutex::new(Vec::new()),
22872289
external_references,
2290+
server_start_time: Instant::now(),
22882291
};
22892292

22902293
if let Some(init_options) = &s.initialize_params.initialization_options {
@@ -2312,6 +2315,7 @@ impl Server {
23122315
has_sourcedb: self.workspaces.sourcedb_available(),
23132316
id: self.id,
23142317
surface: self.surface.clone(),
2318+
server_start_time: self.server_start_time,
23152319
}
23162320
}
23172321

0 commit comments

Comments
 (0)