Skip to content

Commit

Permalink
Add telemetry for too-slow events
Browse files Browse the repository at this point in the history
Summary:
We currently monitor main loop health, and report if it is slower thatn 300ms.

But we are seeing pathological cases for some users where it becomes minutes.

For those cases, have a second telemetry report that tracks the particular event being handled too.

Reviewed By: michalmuskala, robertoaloi

Differential Revision: D58665977

fbshipit-source-id: a5fac108927e3a91b7a95e8863aa90873cea904f
  • Loading branch information
alanz authored and facebook-github-bot committed Jun 17, 2024
1 parent a043fdc commit 26960de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/elp/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ const ERLANG_SERVICE_SUPPORTED_EXTENSIONS: &[FileKind] = &[
FileKind::Escript,
];
const SLOW_DURATION: Duration = Duration::from_millis(300);
/// If the main loop exceeds this time, log the specific request causing the problem
const TOO_SLOW_DURATION: Duration = Duration::from_millis(3000);

enum Event {
Lsp(lsp_server::Message),
Expand Down Expand Up @@ -360,7 +362,8 @@ impl Server {
return Ok(());
}
}
let _timer = timeit_exceeds!("main_loop_health", SLOW_DURATION);
let _timer1 = timeit_exceeds!("main_loop_health", SLOW_DURATION);
let _timer2 = timeit_exceeds!(format!("slow_event:{:?}", event), TOO_SLOW_DURATION);
self.handle_event(event)?;
}

Expand Down

0 comments on commit 26960de

Please sign in to comment.