diff --git a/tracing-trace/src/entry.rs b/tracing-trace/src/entry.rs index 29cf9326c..26e543ba0 100644 --- a/tracing-trace/src/entry.rs +++ b/tracing-trace/src/entry.rs @@ -121,6 +121,11 @@ impl MemoryStats { } } + #[cfg(not(any(target_os = "linux", target_os = "macos")))] + pub fn fetch() -> Option { + None + } + pub fn checked_sub(self, other: Self) -> Option { Some(Self { resident: self.resident.checked_sub(other.resident)? }) } diff --git a/tracing-trace/src/layer.rs b/tracing-trace/src/layer.rs index a2d3232c8..b30e1ad38 100644 --- a/tracing-trace/src/layer.rs +++ b/tracing-trace/src/layer.rs @@ -96,14 +96,8 @@ impl TraceLayer { self.start_time.elapsed() } - #[cfg(any(target_os = "linux", target_os = "macos"))] fn memory_stats(&self) -> Option { - Some(MemoryStats::fetch().unwrap()) - } - - #[cfg(not(any(target_os = "linux", target_os = "macos")))] - fn memory_stats(&self) -> Option { - None + MemoryStats::fetch() } fn send(&self, entry: Entry) {