Skip to content

Commit

Permalink
add support for passing sentry release
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gumpt authored and drcaramelsyrup committed Aug 16, 2024
1 parent fba2c1d commit 07a970e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bb9f706e0012bcb8d6734744c0fa8c4352969450
46345c2f7b66cf4460de73ca2e62c819ab588735
29 changes: 16 additions & 13 deletions pingora-core/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use daemon::daemonize;
use log::{debug, error, info, warn};
use pingora_runtime::Runtime;
use pingora_timeout::fast_timeout;
use sentry::ClientOptions;
use std::sync::Arc;
use std::thread;
use tokio::signal::unix;
Expand Down Expand Up @@ -62,14 +63,14 @@ pub struct Server {
shutdown_watch: watch::Sender<bool>,
// TODO: we many want to drop this copy to let sender call closed()
shutdown_recv: ShutdownWatch,
/// the parsed server configuration
/// The parsed server configuration
pub configuration: Arc<ServerConf>,
/// the parser command line options
/// The parser command line options
pub options: Option<Opt>,
/// the Sentry DSN
/// The Sentry ClientOptions.
///
/// Panics and other events sentry captures will send to this DSN **only in release mode**
pub sentry: Option<String>,
/// Panics and other events sentry captures will be sent to this DSN **only in release mode**
pub sentry: Option<ClientOptions>,
}

// TODO: delete the pid when exit
Expand Down Expand Up @@ -256,10 +257,11 @@ impl Server {

/* only init sentry in release builds */
#[cfg(not(debug_assertions))]
let _guard = match self.sentry.as_ref() {
Some(uri) => Some(sentry::init(uri.as_str())),
None => None,
};
let _guard = self
.sentry
.as_ref()
.map(|opts| sentry::init(opts.clone()))
.expect("sentry ClientOptions are valid");

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

/* only init sentry in release builds */
#[cfg(not(debug_assertions))]
let _guard = match self.sentry.as_ref() {
Some(uri) => Some(sentry::init(uri.as_str())),
None => None,
};
let _guard = self
.sentry
.as_ref()
.map(|opts| sentry::init(opts.clone()))
.expect("sentry ClientOptions are valid");

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

Expand Down

0 comments on commit 07a970e

Please sign in to comment.