Skip to content

Commit 07a970e

Browse files
gumptdrcaramelsyrup
authored andcommitted
add support for passing sentry release
This changes the Sentry field from the DSN string to the entire ClientOptions struct. This will let us pass more information to the client SDK, including the git-parsed version information.
1 parent fba2c1d commit 07a970e

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

.bleep

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bb9f706e0012bcb8d6734744c0fa8c4352969450
1+
46345c2f7b66cf4460de73ca2e62c819ab588735

pingora-core/src/server/mod.rs

+16-13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use daemon::daemonize;
2222
use log::{debug, error, info, warn};
2323
use pingora_runtime::Runtime;
2424
use pingora_timeout::fast_timeout;
25+
use sentry::ClientOptions;
2526
use std::sync::Arc;
2627
use std::thread;
2728
use tokio::signal::unix;
@@ -62,14 +63,14 @@ pub struct Server {
6263
shutdown_watch: watch::Sender<bool>,
6364
// TODO: we many want to drop this copy to let sender call closed()
6465
shutdown_recv: ShutdownWatch,
65-
/// the parsed server configuration
66+
/// The parsed server configuration
6667
pub configuration: Arc<ServerConf>,
67-
/// the parser command line options
68+
/// The parser command line options
6869
pub options: Option<Opt>,
69-
/// the Sentry DSN
70+
/// The Sentry ClientOptions.
7071
///
71-
/// Panics and other events sentry captures will send to this DSN **only in release mode**
72-
pub sentry: Option<String>,
72+
/// Panics and other events sentry captures will be sent to this DSN **only in release mode**
73+
pub sentry: Option<ClientOptions>,
7374
}
7475

7576
// TODO: delete the pid when exit
@@ -256,10 +257,11 @@ impl Server {
256257

257258
/* only init sentry in release builds */
258259
#[cfg(not(debug_assertions))]
259-
let _guard = match self.sentry.as_ref() {
260-
Some(uri) => Some(sentry::init(uri.as_str())),
261-
None => None,
262-
};
260+
let _guard = self
261+
.sentry
262+
.as_ref()
263+
.map(|opts| sentry::init(opts.clone()))
264+
.expect("sentry ClientOptions are valid");
263265

264266
if self.options.as_ref().map_or(false, |o| o.test) {
265267
info!("Server Test passed, exiting");
@@ -303,10 +305,11 @@ impl Server {
303305

304306
/* only init sentry in release builds */
305307
#[cfg(not(debug_assertions))]
306-
let _guard = match self.sentry.as_ref() {
307-
Some(uri) => Some(sentry::init(uri.as_str())),
308-
None => None,
309-
};
308+
let _guard = self
309+
.sentry
310+
.as_ref()
311+
.map(|opts| sentry::init(opts.clone()))
312+
.expect("sentry ClientOptions are valid");
310313

311314
let mut runtimes: Vec<Runtime> = Vec::new();
312315

0 commit comments

Comments
 (0)