From c1b842bf8b439dd01da4c86b5a24fe198ac73bab Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 27 Sep 2022 22:24:21 +0200 Subject: Add Sentry --- src/config.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/config.rs') 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, } impl Configuration { @@ -19,6 +21,19 @@ impl Configuration { cfg.merge(config::Environment::default())?; cfg.try_into() } + + pub fn set_sentry_guard(&self) -> Option { + match &self.sentry_dsn { + Some(dsn) => Some(sentry::init(( + dsn.clone(), + sentry::ClientOptions { + release: sentry::release_name!(), + ..Default::default() + }, + ))), + None => None, + } + } } lazy_static! { -- cgit v1.2.3-71-g8e6c