diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2022-09-27 20:24:21 +0000 |
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2022-09-27 20:24:21 +0000 |
| commit | c1b842bf8b439dd01da4c86b5a24fe198ac73bab (patch) | |
| tree | 7974779ca0e1b0b82ecb304e3163a87269fc1e3e /src/config.rs | |
| parent | 842edd5a75a091a58ea04b6f4d2ef7cf0b0285ea (diff) | |
Add Sentry
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 15 |
1 files changed, 15 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! { |
