Skip to content

Commit 16b6ad3

Browse files
committed
fix(process): don't unwrap when process can't be found
1 parent cfc8b8c commit 16b6ad3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

prometric/src/process.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ impl ProcessCollector {
8484
let system_memory_usage =
8585
self.sys.used_memory() as f64 / self.sys.total_memory() as f64 * 100.0;
8686

87-
let process = self.sys.process(Pid::from_u32(self.pid())).unwrap();
87+
let Some(process) = self.sys.process(Pid::from_u32(self.pid())) else {
88+
return;
89+
};
90+
8891
let cpu_usage = process.cpu_usage() / self.cores as f32;
8992

9093
// Collect thread stats

0 commit comments

Comments
 (0)