diff --git a/crates/amaru/Cargo.toml b/crates/amaru/Cargo.toml index 38a1929..d5a9d88 100644 --- a/crates/amaru/Cargo.toml +++ b/crates/amaru/Cargo.toml @@ -47,6 +47,8 @@ opentelemetry-otlp = { version = "0.27.0", features = [ "reqwest-client", ] } tracing-opentelemetry = { version = "0.28.0" } + +[target.'cfg(not(windows))'.dependencies] sys_metrics = "0.2.7" [dev-dependencies] diff --git a/crates/amaru/src/bin/amaru/metrics.rs b/crates/amaru/src/bin/amaru/metrics.rs index 00548dc..c022ae6 100644 --- a/crates/amaru/src/bin/amaru/metrics.rs +++ b/crates/amaru/src/bin/amaru/metrics.rs @@ -13,6 +13,7 @@ use sys_metrics::{ use tokio::task::JoinHandle; use tracing::warn; +#[cfg(not(windows))] pub fn track_system_metrics(metrics: SdkMeterProvider) -> JoinHandle<()> { tokio::spawn(async move { let counters = make_system_counters(metrics); @@ -40,6 +41,13 @@ pub fn track_system_metrics(metrics: SdkMeterProvider) -> JoinHandle<()> { }) } +#[cfg(windows)] +pub fn track_system_metrics(metrics: SdkMeterProvider) -> JoinHandle<()> { + use tracing::info; + info!("System metrics currently not supported on Windows"); + tokio::spawn(async {}) +} + struct SystemCounters { total_memory: Gauge, free_memory: Gauge, @@ -88,6 +96,7 @@ fn make_system_counters(metrics: SdkMeterProvider) -> SystemCounters { } } +#[cfg(not(windows))] fn get_reading() -> miette::Result { use sys_metrics::*; let memory = memory::get_memory().into_diagnostic()?;