This crate provides support for logging events and errors / panics to the Sentry error logging service. It integrates with the standard panic system in Rust as well as a few popular error handling setups.
The most convenient way to use this library is via the sentry::init
function,
which starts a sentry client with a default set of integrations, and binds
it to the current Hub
.
The sentry::init
function returns a guard that when dropped will flush Events that were not
yet sent to the sentry service. It has a two second deadline for this so shutdown of
applications might slightly delay as a result of this. Keep the guard around or sending events
will not work.
let _guard = sentry::init("https://[email protected]/42");
sentry::capture_message("Hello World!", sentry::Level::Info);
// when the guard goes out of scope here, the client will wait up to two
// seconds to send remaining events to the service.
More complex examples on how to use sentry can also be found in examples. Extended instructions may also be found on Sentry itself.
What makes this crate useful are its various integrations. Some of them are enabled by default; See Features. Uncommon integrations or integrations for deprecated parts of the ecosystem require a feature flag. For available integrations and how to use them, see integrations and apply_defaults.
This crate comes fully-featured. If the goal is to instrument libraries for usage
with sentry, or to extend sentry with a custom Integration
or a Transport
,
one should use the sentry-core
crate instead.
Additional functionality and integrations are enabled via feature flags. Some features require extra setup to function properly.
Feature | Default | Is Integration | Deprecated | Additional notes |
---|---|---|---|---|
backtrace |
✅ | 🔌 | ||
contexts |
✅ | 🔌 | ||
panic |
✅ | 🔌 | ||
transport |
✅ | |||
anyhow |
🔌 | |||
test |
||||
debug-images |
🔌 | |||
log |
🔌 | Requires extra setup; See sentry-log 's documentation. |
||
debug-logs |
❗ | Requires extra setup; See sentry-log 's documentation. |
||
slog |
🔌 | Requires extra setup; See sentry-slog 's documentation. |
||
reqwest |
✅ | |||
native-tls |
✅ | reqwest must be enabled. |
||
rustls |
reqwest must be enabled. native-tls must be disabled via default-features = false . |
|||
curl |
||||
surf |
||||
tower |
🔌 | Requires extra setup; See sentry-tower 's documentation. |
||
ureq |
ureq transport support using rustls by default |
|||
ureq-native-tls |
backtrace
: Enables backtrace support.contexts
: Enables capturing device, OS, and Rust contexts.panic
: Enables support for capturing panics.transport
: Enables the default transport, which is currentlyreqwest
withnative-tls
.
anyhow
: Enables support for theanyhow
crate.test
: Enables testing support.debug-images
: Attaches a list of loaded libraries to events (currently only supported on Unix).
log
: Enables support for thelog
crate.slog
: Enables support for theslog
crate.debug-logs
: Deprecated. Uses thelog
crate for internal logging.
reqwest
: Default. Enables thereqwest
transport.native-tls
: Default. Uses thenative-tls
crate. This only affects thereqwest
transport.rustls
: Enablesrustls
support forreqwest
. Please note thatnative-tls
is a default feature, anddefault-features = false
must be set to completely disable buildingnative-tls
dependencies.curl
: Enables thecurl
transport.surf
: Enables thesurf
transport.ureq
: Enables theureq
transport usingrustls
.ureq-native-tls
: Enables theureq
transport usingnative-tls
.
tower
: Enables support for thetower
crate and those using it.
License: Apache-2.0
- Discord server for project discussions.
- Follow @getsentry on Twitter for updates