diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.rs | 15 | ||||
| -rw-r--r-- | src/main.rs | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index 0d266bf..b86d018 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,6 @@ pub use config::ConfigError; use lazy_static::lazy_static; +use sentry::ClientInitGuard; use serde::Deserialize; #[derive(Deserialize)] @@ -11,6 +12,7 @@ pub struct Configuration { pub database_url: String, pub jwt_secret: String, pub allowed_host: String, + pub sentry_dsn: Option<String>, } impl Configuration { @@ -19,6 +21,19 @@ impl Configuration { cfg.merge(config::Environment::default())?; cfg.try_into() } + + pub fn set_sentry_guard(&self) -> Option<ClientInitGuard> { + match &self.sentry_dsn { + Some(dsn) => Some(sentry::init(( + dsn.clone(), + sentry::ClientOptions { + release: sentry::release_name!(), + ..Default::default() + }, + ))), + None => None, + } + } } lazy_static! { diff --git a/src/main.rs b/src/main.rs index b13be75..dac14e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,14 @@ async fn main() { let app = create_app().await; let host = &CONFIG.allowed_host; + + match CONFIG.set_sentry_guard() { + Some(_) => {} + None => { + tracing::error!("Sentry not configured."); + } + }; + let addr = match host.parse::<SocketAddr>() { Ok(addr) => addr, Err(_) => match host.to_socket_addrs() { |
