mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
chore(gui-client): log uptime and run ID when a window is shown (#3913)
I want to make sure there aren't bugs that prevent the GUI clients from reaching high uptime, so this makes it easy to check the uptime with e.g. `tail -f`. The run IDs would let us re-construct when the app restarts. "chore" doesn't seem right but it's not a user-facing feature, test, doc, fix, or refactor, either. Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,7 @@ mod network_changes;
|
||||
mod resolvers;
|
||||
mod settings;
|
||||
mod updates;
|
||||
mod uptime;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
mod wintun_install;
|
||||
|
||||
@@ -503,6 +503,7 @@ struct Controller {
|
||||
/// Tells us when to wake up and look for a new resource list. Tokio docs say that memory reads and writes are synchronized when notifying, so we don't need an extra mutex on the resources.
|
||||
notify_controller: Arc<Notify>,
|
||||
tunnel_ready: bool,
|
||||
uptime: client::uptime::Tracker,
|
||||
}
|
||||
|
||||
/// Everything related to a signed-in user session
|
||||
@@ -634,7 +635,18 @@ impl Controller {
|
||||
self.sign_out()?;
|
||||
}
|
||||
}
|
||||
Req::SystemTrayMenu(TrayMenuEvent::ShowWindow(window)) => self.show_window(window)?,
|
||||
Req::SystemTrayMenu(TrayMenuEvent::ShowWindow(window)) => {
|
||||
self.show_window(window)?;
|
||||
// When the About or Settings windows are hidden / shown, log the
|
||||
// run ID and uptime. This makes it easy to check client stability on
|
||||
// dev or test systems without parsing the whole log file.
|
||||
let uptime_info = self.uptime.info();
|
||||
tracing::debug!(
|
||||
uptime_s = uptime_info.uptime.as_secs(),
|
||||
run_id = uptime_info.run_id.to_string(),
|
||||
"Uptime info"
|
||||
);
|
||||
}
|
||||
Req::SystemTrayMenu(TrayMenuEvent::Resource { id }) => self
|
||||
.copy_resource(&id)
|
||||
.context("Couldn't copy resource to clipboard")?,
|
||||
@@ -784,6 +796,7 @@ async fn run_controller(
|
||||
logging_handles,
|
||||
notify_controller,
|
||||
tunnel_ready: false,
|
||||
uptime: Default::default(),
|
||||
};
|
||||
|
||||
if let Some(token) = controller
|
||||
|
||||
31
rust/gui-client/src-tauri/src/client/uptime.rs
Normal file
31
rust/gui-client/src-tauri/src/client/uptime.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use std::time::Duration;
|
||||
use tokio::time::Instant;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct Tracker {
|
||||
run_id: Uuid,
|
||||
start_time: Instant,
|
||||
}
|
||||
|
||||
pub struct Info {
|
||||
pub run_id: Uuid,
|
||||
pub uptime: Duration,
|
||||
}
|
||||
|
||||
impl Default for Tracker {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
start_time: Instant::now(),
|
||||
run_id: Uuid::new_v4(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Tracker {
|
||||
pub fn info(&self) -> Info {
|
||||
Info {
|
||||
run_id: self.run_id,
|
||||
uptime: Instant::now() - self.start_time,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user