summaryrefslogtreecommitdiffstats
path: root/rust/src/bin
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-09 14:59:56 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-09 15:09:24 -0800
commitd13f2d6a6d452970c019147cd95e4d27e79799fa (patch)
treeb0ec0399d3869406ea2ae3ed00b1eabde2575a73 /rust/src/bin
parent995a6dcc8939aa8dcc8927ce18c9cd1ba0fd9473 (diff)
downloadfatcat-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.rs16
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,