Skip to content

Commit

Permalink
Disable system metrics on windows until the dependency supports windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumplation committed Jan 10, 2025
1 parent d5a0185 commit 2d86c88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/amaru/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 9 additions & 0 deletions crates/amaru/src/bin/amaru/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<u64>,
free_memory: Gauge<u64>,
Expand Down Expand Up @@ -88,6 +96,7 @@ fn make_system_counters(metrics: SdkMeterProvider) -> SystemCounters {
}
}

#[cfg(not(windows))]
fn get_reading() -> miette::Result<Reading> {
use sys_metrics::*;
let memory = memory::get_memory().into_diagnostic()?;
Expand Down

0 comments on commit 2d86c88

Please sign in to comment.