Browse Source

Warn if event handling takes too long in daemon or coordinator

tags/v0.3.12-rc0
Philipp Oppermann 9 months ago
parent
commit
63c548991f
Failed to extract signature
2 changed files with 22 additions and 0 deletions
  1. +11
    -0
      binaries/coordinator/src/lib.rs
  2. +11
    -0
      binaries/daemon/src/lib.rs

+ 11
- 0
binaries/coordinator/src/lib.rs View File

@@ -201,6 +201,9 @@ async fn start_inner(
let mut daemon_connections = DaemonConnections::default();

while let Some(event) = events.next().await {
let start = Instant::now();
let event_debug = format!("{event:?}");

if event.log() {
tracing::trace!("Handling event {event:?}");
}
@@ -704,6 +707,14 @@ async fn start_inner(
daemon_connections.remove(&daemon_id);
}
}

let elapsed = start.elapsed();
if elapsed > Duration::from_millis(100) {
tracing::warn!(
"Coordinator took {}ms for handling event: {event_debug}",
elapsed.as_millis()
);
}
}

tracing::info!("stopped");


+ 11
- 0
binaries/daemon/src/lib.rs View File

@@ -320,6 +320,9 @@ impl Daemon {
tracing::warn!("failed to update HLC with incoming event timestamp: {err}");
}

let start = Instant::now();
let event_debug = format!("{inner:?}");

match inner {
Event::Coordinator(CoordinatorEvent { event, reply_tx }) => {
let status = self.handle_coordinator_event(event, reply_tx).await?;
@@ -406,6 +409,14 @@ impl Daemon {
}
},
}

let elapsed = start.elapsed();
if elapsed > Duration::from_millis(100) {
tracing::warn!(
"Daemon took {}ms for handling event: {event_debug}",
elapsed.as_millis()
);
}
}

if let Some(mut connection) = self.coordinator_connection.take() {


Loading…
Cancel
Save