From 5e7495a0420490e731a4ea8c466b8ef7e0b5f062 Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 3 Mar 2026 20:41:37 +0800 Subject: [PATCH] build(obs): restrict pyroscope dependency to unix targets (#2064) --- crates/obs/Cargo.toml | 4 +++- crates/obs/src/telemetry/otel.rs | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/obs/Cargo.toml b/crates/obs/Cargo.toml index bbe0fbefa..b401eed99 100644 --- a/crates/obs/Cargo.toml +++ b/crates/obs/Cargo.toml @@ -56,9 +56,11 @@ tracing-subscriber = { workspace = true, features = ["registry", "std", "fmt", " tokio = { workspace = true, features = ["sync", "fs", "rt-multi-thread", "rt", "time", "macros"] } sysinfo = { workspace = true } thiserror = { workspace = true } -pyroscope = { workspace = true, features= ["backend-pprof-rs"]} walkdir = { workspace = true } +[target.'cfg(unix)'.dependencies] +pyroscope = { workspace = true, features = ["backend-pprof-rs"] } + [dev-dependencies] tokio = { workspace = true, features = ["full"] } diff --git a/crates/obs/src/telemetry/otel.rs b/crates/obs/src/telemetry/otel.rs index 8da6d42c2..89bfe5d6a 100644 --- a/crates/obs/src/telemetry/otel.rs +++ b/crates/obs/src/telemetry/otel.rs @@ -49,10 +49,6 @@ use opentelemetry_sdk::{ metrics::{PeriodicReader, SdkMeterProvider}, trace::{RandomIdGenerator, Sampler, SdkTracerProvider}, }; -#[cfg(unix)] -use pyroscope::PyroscopeAgent; -#[cfg(unix)] -use pyroscope::pyroscope::PyroscopeAgentRunning; use rustfs_config::{ APP_NAME, DEFAULT_OBS_LOG_STDOUT_ENABLED, DEFAULT_OBS_LOGS_EXPORT_ENABLED, DEFAULT_OBS_METRICS_EXPORT_ENABLED, DEFAULT_OBS_PROFILING_EXPORT_ENABLED, DEFAULT_OBS_TRACES_EXPORT_ENABLED, METER_INTERVAL, SAMPLE_RATIO, @@ -321,7 +317,7 @@ fn build_logger_provider( /// Starts the Pyroscope continuous profiling agent if `ENV_OBS_PROFILING_ENDPOINT` is set. /// No-op and returns None on non-unix platforms. #[cfg(unix)] -fn init_profiler(config: &OtelConfig) -> Option> { +fn init_profiler(config: &OtelConfig) -> Option> { use pyroscope::backend::{BackendConfig, PprofConfig, pprof_backend}; use pyroscope::pyroscope::PyroscopeAgentBuilder; use rustfs_config::VERSION;