From 232614246229ff23f483e666abc43b93178534a0 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Fri, 27 Sep 2024 09:24:16 -0700 Subject: feat(core): make 'sentry' optional Co-authored-by: Grvzard --- .bleep | 2 +- pingora-core/Cargo.toml | 2 +- pingora-core/src/server/mod.rs | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.bleep b/.bleep index 85da7eb..5859e11 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -ca6a894f27f4448b3d0fe7ab3d84221133e83e5b \ No newline at end of file +e2493b0330def4631d98161f1f0a477b440f3a85 \ No newline at end of file diff --git a/pingora-core/Cargo.toml b/pingora-core/Cargo.toml index 3534aea..5fa60ae 100644 --- a/pingora-core/Cargo.toml +++ b/pingora-core/Cargo.toml @@ -26,7 +26,7 @@ pingora-pool = { version = "0.3.0", path = "../pingora-pool" } pingora-error = { version = "0.3.0", path = "../pingora-error" } pingora-timeout = { version = "0.3.0", path = "../pingora-timeout" } pingora-http = { version = "0.3.0", path = "../pingora-http" } -tokio = { workspace = true, features = ["rt-multi-thread", "signal"] } +tokio = { workspace = true, features = ["net", "rt-multi-thread", "signal"] } futures = "0.3" async-trait = { workspace = true } httparse = { workspace = true } diff --git a/pingora-core/src/server/mod.rs b/pingora-core/src/server/mod.rs index d28b00c..c86c49e 100644 --- a/pingora-core/src/server/mod.rs +++ b/pingora-core/src/server/mod.rs @@ -76,6 +76,7 @@ pub struct Server { /// The parser command line options pub options: Option, #[cfg(feature = "sentry")] + #[cfg_attr(docsrs, doc(cfg(feature = "sentry")))] /// The Sentry ClientOptions. /// /// Panics and other events sentry captures will be sent to this DSN **only in release mode** @@ -126,7 +127,7 @@ impl Server { Err(e) => { error!("Unable to send listener sockets to new process: {e}"); // sentry log error on fd send failure - #[cfg(not(debug_assertions))] + #[cfg(all(not(debug_assertions), feature = "sentry"))] sentry::capture_error(&e); } } @@ -276,7 +277,7 @@ impl Server { debug!("{:#?}", self.options); /* only init sentry in release builds */ - #[cfg(not(debug_assertions))] + #[cfg(all(not(debug_assertions), feature = "sentry"))] let _guard = self.sentry.as_ref().map(|opts| sentry::init(opts.clone())); if self.options.as_ref().map_or(false, |o| o.test) { @@ -292,7 +293,7 @@ impl Server { } Err(e) => { // sentry log error on fd load failure - #[cfg(not(debug_assertions))] + #[cfg(all(not(debug_assertions), feature = "sentry"))] sentry::capture_error(&e); error!("Bootstrap failed on error: {:?}, exiting.", e); @@ -327,7 +328,7 @@ impl Server { } /* only init sentry in release builds */ - #[cfg(not(debug_assertions))] + #[cfg(all(not(debug_assertions), feature = "sentry"))] let _guard = self.sentry.as_ref().map(|opts| sentry::init(opts.clone())); let mut runtimes: Vec = Vec::new(); -- cgit v1.2.3