Skip to content

Instantly share code, notes, and snippets.

@fry
Created June 27, 2019 10:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fry/1b8e3164c87e9e41d9e0a220cb4144d9 to your computer and use it in GitHub Desktop.
Save fry/1b8e3164c87e9e41d9e0a220cb4144d9 to your computer and use it in GitHub Desktop.
Sentry Setup in Dynamic Libraries
lazy_static! {
static ref GUARD: Mutex<Option<sentry::internals::ClientInitGuard>> = Mutex::new(None);
}
*GUARD.lock().unwrap() = Some(sentry::init(dotenv!("SENTRY_DSN")));
sentry::integrations::panic::register_panic_handler();
let next = panic::take_hook();
panic::set_hook(Box::new(move |info| {
next(info);
// Dropping the guard here ensures Sentry actually finishes sending the report
let _guard = GUARD.lock().unwrap().take();
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment