diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-09 14:59:56 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-09 15:09:24 -0800 |
commit | d13f2d6a6d452970c019147cd95e4d27e79799fa (patch) | |
tree | b0ec0399d3869406ea2ae3ed00b1eabde2575a73 /rust/src/bin | |
parent | 995a6dcc8939aa8dcc8927ce18c9cd1ba0fd9473 (diff) | |
download | fatcat-d13f2d6a6d452970c019147cd95e4d27e79799fa.tar.gz fatcat-d13f2d6a6d452970c019147cd95e4d27e79799fa.zip |
wire up basic sentry error reporting
Diffstat (limited to 'rust/src/bin')
-rw-r--r-- | rust/src/bin/fatcatd.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/rust/src/bin/fatcatd.rs b/rust/src/bin/fatcatd.rs index 34652105..388c6e61 100644 --- a/rust/src/bin/fatcatd.rs +++ b/rust/src/bin/fatcatd.rs @@ -12,7 +12,9 @@ use iron::middleware::AfterMiddleware; use iron::modifiers::RedirectRaw; use iron::{status, Chain, Iron, IronResult, Request, Response}; use iron_slog::{DefaultLogFormatter, LoggerMiddleware}; +use sentry::integrations::panic; use slog::{Drain, Logger}; +use std::env; // HTTP header middleware header! { (XClacksOverhead, "X-Clacks-Overhead") => [String] } @@ -38,12 +40,26 @@ fn main() -> Result<()> { ) .get_matches(); + dotenv::dotenv().ok(); + let decorator = slog_term::TermDecorator::new().build(); let drain = slog_term::CompactFormat::new(decorator).build().fuse(); let drain = slog_async::Async::new(drain).build().fuse(); let logger = Logger::root(drain, o!()); let formatter = DefaultLogFormatter; + // sentry exception handling + let sentry_dsn = env::var("SENTRY_DSN"); + let _guard = if let Ok(dsn) = sentry_dsn { + let client = sentry::init(dsn); + panic::register_panic_handler(); + info!(logger, "Sentry configured via DSN"); + Some(client) + } else { + info!(logger, "Sentry not configured"); + None + }; + let server = create_server()?; info!( logger, |