sentry-rust
sentry-rust copied to clipboard
eyre and color-eyre integration
It would be good to have support for eyre/color-eyre too along with #180
Maintainer of eyre/color-eyre here. At work we're in the process of integrating sentry with our application. I got some basic integration setup but the sentry
UI doesn't seem to parse ansi codes, so I'm leaning towards writing our own panic integration rather than relying on color-eyre's panic reporting. I haven't really figured out what level of integration I want to get out of eyre::Report
s, I'll have to look into how the anyhow
integration is setup.
Once we've got it figured out though I'll be happy to upstream any integration we end up writing.
Here's what a color-eyre report looks like in the sentry UI:
Using this minimal setup code (ty again for the API @kellpossible ^_^):
let builder = color_eyre::config::HookBuilder::default()
.theme(theme)
.issue_url(concat!(env!("CARGO_PKG_REPOSITORY"), "/issues/new"))
.add_issue_metadata("version", env!("CARGO_PKG_VERSION"))
.add_issue_metadata("git commit", Self::git_commit())
.issue_filter(|kind| match kind {
color_eyre::ErrorKind::NonRecoverable(_) => true,
color_eyre::ErrorKind::Recoverable(error) => {
!error.is::<tower::timeout::error::Elapsed>()
}
});
let (panic_hook, eyre_hook) = builder.into_hooks();
eyre_hook.install().unwrap();
// The Sentry default config pulls in the DSN from the `SENTRY_DSN`
// environment variable.
let guard = sentry::init(
sentry::ClientOptions {
debug: true,
..Default::default()
}
.add_integration(sentry_tracing::TracingIntegration::default()),
);
std::panic::set_hook(Box::new(move |panic_info| {
let panic_report = panic_hook.panic_report(panic_info).to_string();
let event = sentry::protocol::Event {
exception: vec![sentry::protocol::Exception {
ty: "panic".into(),
mechanism: Some(sentry::protocol::Mechanism {
ty: "panic".into(),
handled: Some(false),
..Default::default()
}),
value: Some(panic_report),
stacktrace: sentry::integrations::backtrace::current_stacktrace(),
..Default::default()
}]
.into(),
level: sentry::Level::Fatal,
..Default::default()
};
sentry::capture_event(event);
// required because we use `panic = abort`
if !guard.close(None) {
warn!("unable to flush sentry events during panic");
}
}));
panic!("fancy foo");
Is there an eyre counterpart for sentry_anyhow::capture_anyhow
?
Is there an eyre counterpart for
sentry_anyhow::capture_anyhow
?
Sorry for the long delay. No, there isn't, at least not within Sentry.