diff options
author | Matthew Gumport <[email protected]> | 2024-08-13 18:21:13 -0700 |
---|---|---|
committer | Edward Wang <[email protected]> | 2024-08-16 10:36:11 -0700 |
commit | b0bd0fb0c9357e0edc6b7732116e268c934eabaf (patch) | |
tree | 0a8740f62108a18a23ec20e3fbd7bb84f1051d1f | |
parent | 07a970e413009ee62fc4c15e0820ae1aa036af22 (diff) | |
download | pingora-b0bd0fb0c9357e0edc6b7732116e268c934eabaf.tar.gz pingora-b0bd0fb0c9357e0edc6b7732116e268c934eabaf.zip |
fixup sentry unwrap
Don't unconditionally unwrap Sentry, guard it with a default value.
-rw-r--r-- | .bleep | 2 | ||||
-rw-r--r-- | docs/user_guide/panic.md | 7 | ||||
-rw-r--r-- | pingora-core/src/server/mod.rs | 12 |
3 files changed, 9 insertions, 12 deletions
@@ -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 58bf19d..b2e0626 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 5fdecb2..c3659f2 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<Runtime> = Vec::new(); |