From 17b385a985e7b628ad8d86520671e3b99db1f25f Mon Sep 17 00:00:00 2001 From: Yingwen Date: Sun, 8 Oct 2023 16:28:45 +0800 Subject: [PATCH] fix: compiler errors under `pprof` and `mem-prof` features (#2537) * fix: compiler errors under pprof feature * fix: compiler errors under mem-prof feature --- src/servers/src/error.rs | 7 ++++--- src/servers/src/http.rs | 2 +- src/servers/src/http/pprof.rs | 2 +- src/servers/src/http/pprof/nix.rs | 16 +++++++++++----- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/servers/src/error.rs b/src/servers/src/error.rs index 8647b60cdd..3efc2d3c65 100644 --- a/src/servers/src/error.rs +++ b/src/servers/src/error.rs @@ -278,8 +278,7 @@ pub enum Error { #[snafu(display("Failed to dump profile data"))] DumpProfileData { location: Location, - #[snafu(source)] - error: common_mem_prof::error::Error, + source: common_mem_prof::error::Error, }, #[snafu(display("Invalid prepare statement: {}", err_msg))] @@ -335,7 +334,9 @@ pub enum Error { #[cfg(feature = "pprof")] #[snafu(display("Failed to dump pprof data"))] - DumpPprof { source: common_pprof::Error }, + DumpPprof { + source: crate::http::pprof::nix::Error, + }, #[snafu(display(""))] Metrics { source: BoxedError }, diff --git a/src/servers/src/http.rs b/src/servers/src/http.rs index 1e9660e938..d6fbd8e49d 100644 --- a/src/servers/src/http.rs +++ b/src/servers/src/http.rs @@ -19,7 +19,7 @@ pub mod influxdb; pub mod mem_prof; pub mod opentsdb; pub mod otlp; -mod pprof; +pub mod pprof; pub mod prom_store; pub mod prometheus; pub mod script; diff --git a/src/servers/src/http/pprof.rs b/src/servers/src/http/pprof.rs index 3e8ed55ac0..23a9a2c2cb 100644 --- a/src/servers/src/http/pprof.rs +++ b/src/servers/src/http/pprof.rs @@ -13,7 +13,7 @@ // limitations under the License. #[cfg(feature = "pprof")] -mod nix; +pub(crate) mod nix; #[cfg(feature = "pprof")] pub mod handler { diff --git a/src/servers/src/http/pprof/nix.rs b/src/servers/src/http/pprof/nix.rs index 5c87bd0362..4b9c091888 100644 --- a/src/servers/src/http/pprof/nix.rs +++ b/src/servers/src/http/pprof/nix.rs @@ -17,32 +17,38 @@ use std::time::Duration; use common_error::ext::ErrorExt; use common_error::status_code::StatusCode; +use common_macro::stack_trace_debug; use prost::Message; use snafu::{Location, ResultExt, Snafu}; -#[derive(Debug, Snafu)] +#[derive(Snafu)] +#[stack_trace_debug] pub enum Error { #[snafu(display("Failed to create profiler guard"))] CreateGuard { - source: pprof::Error, + #[snafu(source)] + error: pprof::Error, location: Location, }, #[snafu(display("Failed to create report"))] CreateReport { - source: pprof::Error, + #[snafu(source)] + error: pprof::Error, location: Location, }, #[snafu(display("Failed to create flamegraph"))] CreateFlamegraph { - source: pprof::Error, + #[snafu(source)] + error: pprof::Error, location: Location, }, #[snafu(display("Failed to create pprof report"))] ReportPprof { - source: pprof::Error, + #[snafu(source)] + error: pprof::Error, location: Location, }, }