From 1c0c44ec3ca8b1c7f8c74bffef8af23830262a33 Mon Sep 17 00:00:00 2001 From: jasonwitty Date: Wed, 3 Jun 2026 11:15:45 -0700 Subject: [PATCH] fix(agent): gate `now` binding to logging feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Windows CI matrix surfaced an `unused_variables` warning at metrics.rs:846 — `let now = std::time::Instant::now();` was bound unconditionally but only consumed inside a `#[cfg(feature = "logging")]` tracing::debug! call. This block lives in the non-Linux `collect_processes_all`, so the Linux CI never compiles it and never sees the warning. Same shape as the `processes_ttl_ms` Windows fix from earlier: a binding whose only consumer is cfg-gated needs to be cfg-gated too. Co-Authored-By: Claude Opus 4.7 (1M context) --- socktop_agent/src/metrics.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/socktop_agent/src/metrics.rs b/socktop_agent/src/metrics.rs index ca7c4f7..0600fe6 100644 --- a/socktop_agent/src/metrics.rs +++ b/socktop_agent/src/metrics.rs @@ -843,6 +843,13 @@ pub async fn collect_processes_all(state: &AppState) -> ProcessesPayload { let cache_cleanup_threshold = name_cache_cleanup_threshold(); if total_count > proc_cache.names.len() + cache_cleanup_threshold { + // `now` is only consumed by the `tracing::debug!` below, so gate + // the binding with the same cfg as its consumer. Without this, + // a non-logging build (the default) emits an unused-variable + // warning. The Linux CI doesn't catch it because this block lives + // in the `#[cfg(not(target_os = "linux"))]` collect_processes_all — + // the warning only surfaces on the Windows build matrix. + #[cfg(feature = "logging")] let now = std::time::Instant::now(); proc_cache .names