diff options
author | Matthew Gumport <[email protected]> | 2024-08-12 09:56:11 -0700 |
---|---|---|
committer | Edward Wang <[email protected]> | 2024-08-16 10:36:11 -0700 |
commit | 07a970e413009ee62fc4c15e0820ae1aa036af22 (patch) | |
tree | 08e613825dbc4c47257a3edb39c2267d6252fcfd /pingora-core | |
parent | fba2c1df115fab18959c31978248c899444ef47d (diff) | |
download | pingora-07a970e413009ee62fc4c15e0820ae1aa036af22.tar.gz pingora-07a970e413009ee62fc4c15e0820ae1aa036af22.zip |
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.
Diffstat (limited to 'pingora-core')
-rw-r--r-- | pingora-core/src/server/mod.rs | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/pingora-core/src/server/mod.rs b/pingora-core/src/server/mod.rs index 8ebf6fd..5fdecb2 100644 --- a/pingora-core/src/server/mod.rs +++ b/pingora-core/src/server/mod.rs @@ -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; @@ -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 @@ -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"); @@ -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(); |