1
0
mirror of https://github.com/actix/actix-website synced 2024-11-24 08:43:01 +01:00
actix-website/content/docs/sentry.md

39 lines
1.4 KiB
Markdown
Raw Normal View History

2018-05-22 23:15:08 +02:00
---
title: Sentry
menu: docs_patterns
weight: 1020
---
# Sentry Crash Reporting
[Sentry][sentrysite] is a crash reporting system that supports the failure crate which
is the base of the actix error reporting. With a middleware it's possible to
automatically report server errors to Sentry.
2018-05-22 23:15:08 +02:00
# Middleware
This middleware captures any error in the server error range (500 - 599)
and sends the attached error to sentry with its stacktrace.
To use the middleware the [sentry crate][sentrycrate] needs to be initialized and configured
and the [sentry-actix middleware][sentrymiddleware] needs to be added. Additionally it
makes sense to also register the panic handler to be informed about hard panics.
2018-05-22 23:15:08 +02:00
2019-06-18 08:42:43 +02:00
{{< include-example example="sentry" file="main.rs" section="middleware" >}}
# Reusing the Hub
If you use this integration the default sentry hub (`Hub::current()`) is typically the wrong one.
To get the request specific one you need to use the `ActixWebHubExt` trait:
2019-06-18 08:42:43 +02:00
{{< include-example example="sentry" file="main.rs" section="hub" >}}
The hub can also be made current for the duration of a call. Then `Hub::current()` works correctly
until the end of the `run` block.
2019-06-18 08:42:43 +02:00
{{< include-example example="sentry" file="main.rs" section="hub2" >}}
[sentrysite]: https://sentry.io/
[sentrycrate]: https://crates.io/crates/sentry
[sentrymiddleware]: https://crates.io/crates/sentry-actix