From b0bd0fb0c9357e0edc6b7732116e268c934eabaf Mon Sep 17 00:00:00 2001 From: Matthew Gumport Date: Tue, 13 Aug 2024 18:21:13 -0700 Subject: [PATCH] fixup sentry unwrap Don't unconditionally unwrap Sentry, guard it with a default value. --- .bleep | 2 +- docs/user_guide/panic.md | 7 ++++++- pingora-core/src/server/mod.rs | 12 ++---------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.bleep b/.bleep index 85a7e4b4..ceecaa73 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -46345c2f7b66cf4460de73ca2e62c819ab588735 \ No newline at end of file +d2eaddcd278a00f25792bf06f046b39aa321abe3 \ No newline at end of file diff --git a/docs/user_guide/panic.md b/docs/user_guide/panic.md index 58bf19d8..b2e0626e 100644 --- a/docs/user_guide/panic.md +++ b/docs/user_guide/panic.md @@ -4,7 +4,12 @@ Any panic that happens to particular requests does not affect other ongoing requ In order to monitor the panics, Pingora server has built-in Sentry integration. ```rust -my_server.sentry = Some("SENTRY_DSN"); +my_server.sentry = Some( + sentry::ClientOptions{ + dsn: "SENTRY_DSN".into_dsn().unwrap(), + ..Default::default() + } +); ``` Even though a panic is not fatal in Pingora, it is still not the preferred way to handle failures like network timeouts. Panics should be reserved for unexpected logic errors. diff --git a/pingora-core/src/server/mod.rs b/pingora-core/src/server/mod.rs index 5fdecb2e..c3659f2a 100644 --- a/pingora-core/src/server/mod.rs +++ b/pingora-core/src/server/mod.rs @@ -257,11 +257,7 @@ impl Server { /* only init sentry in release builds */ #[cfg(not(debug_assertions))] - let _guard = self - .sentry - .as_ref() - .map(|opts| sentry::init(opts.clone())) - .expect("sentry ClientOptions are valid"); + let _guard = self.sentry.as_ref().map(|opts| sentry::init(opts.clone())); if self.options.as_ref().map_or(false, |o| o.test) { info!("Server Test passed, exiting"); @@ -305,11 +301,7 @@ impl Server { /* only init sentry in release builds */ #[cfg(not(debug_assertions))] - let _guard = self - .sentry - .as_ref() - .map(|opts| sentry::init(opts.clone())) - .expect("sentry ClientOptions are valid"); + let _guard = self.sentry.as_ref().map(|opts| sentry::init(opts.clone())); let mut runtimes: Vec = Vec::new();