Skip to content

Commit

Permalink
fixup sentry unwrap
Browse files Browse the repository at this point in the history
Don't unconditionally unwrap Sentry, guard it with a default value.
  • Loading branch information
gumpt authored and drcaramelsyrup committed Aug 16, 2024
1 parent 07a970e commit b0bd0fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
46345c2f7b66cf4460de73ca2e62c819ab588735
d2eaddcd278a00f25792bf06f046b39aa321abe3
7 changes: 6 additions & 1 deletion docs/user_guide/panic.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
12 changes: 2 additions & 10 deletions pingora-core/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit b0bd0fb

Please sign in to comment.