From 07a970e413009ee62fc4c15e0820ae1aa036af22 Mon Sep 17 00:00:00 2001 From: Matthew Gumport Date: Mon, 12 Aug 2024 09:56:11 -0700 Subject: [PATCH] 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. --- .bleep | 2 +- pingora-core/src/server/mod.rs | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.bleep b/.bleep index c40e0dc..85a7e4b 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -bb9f706e0012bcb8d6734744c0fa8c4352969450 \ No newline at end of file +46345c2f7b66cf4460de73ca2e62c819ab588735 \ No newline at end of file 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, // 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, - /// the parser command line options + /// The parser command line options pub options: Option, - /// the Sentry DSN + /// The Sentry ClientOptions. /// - /// Panics and other events sentry captures will send to this DSN **only in release mode** - pub sentry: Option, + /// Panics and other events sentry captures will be sent to this DSN **only in release mode** + pub sentry: Option, } // 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 = Vec::new();