[−][src]Crate sentry
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.
Quickstart
The most convenient way to use this library is 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://key@sentry.io/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.
Integrations
What makes this crate useful are the various integrations that exist. Some of them are enabled by default, some uncommon ones or for deprecated parts of the ecosystem a feature flag needs to be enabled. For the available integrations and how to use them see integrations and apply_defaults.
Minimal API
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.
Features
Functionality of the crate can be turned on and off by feature flags. This is the current list of feature flags:
Default features:
backtrace
: Enables backtrace support.contexts
: Enables capturing device, os, and rust contexts.failure
: Enables support for thefailure
crate.panic
: Enables support for capturing panics.transport
: Enables the default transport, which is currentlyreqwest
withnative-tls
.
Additional features:
anyhow
: Enables support for theanyhow
crate.debug-images
: Attaches a list of loaded libraries to events (currently only supported on unix).error-chain
: Enables support for theerror-chain
crate.log
: Enables support for thelog
crate.slog
: Enables support for theslog
crate.test
: Enables testing support.debug-logs
: Uses thelog
crate for internal logging.reqwest
: Enables thereqwest
transport, which is currently the default.curl
: Enables the curl transport.surf
: Enables the surf transport.native-tls
: Uses thenative-tls
crate, which is currently the default. This only has an effect on thereqwest
transport.rustls
: Enables therustls
support of thereqwest
transport.
Modules
integrations | Available Sentry Integrations. |
internals | Deprecated Useful internals. |
protocol | The current latest sentry protocol version. |
test | This provides testing functionality for building tests. |
transports | The provided transports. |
types | This crate provides common types for working with the Sentry protocol or the Sentry server. It's used by the Sentry Relay infrastructure as well as the rust Sentry client. |
Macros
release_name | Returns the intended release for Sentry as an |
Structs
Breadcrumb | Represents a single breadcrumb. |
Client | The Sentry Client. |
ClientInitGuard | Helper struct that is returned from |
ClientOptions | Configuration settings for the client. |
Future | A future that binds a |
Hub | The central object that can manages scopes and clients. |
Scope | Holds contextual data for the current scope. |
ScopeGuard | A scope guard. |
User | Represents user info. |
Enums
Level | Represents the level of severity of an event or breadcrumb. |
Traits
FutureExt | Future extensions for Sentry. |
Integration | Integration abstraction. |
IntoBreadcrumbs | A helper trait that converts self into an Iterator of Breadcrumbs. |
IntoDsn | Helper trait to convert a string into an |
Transport | The trait for transports. |
TransportFactory | A factory creating transport instances. |
Functions
add_breadcrumb | Records a breadcrumb by calling a function. |
apply_defaults | Apply default client options. |
capture_error | Captures a |
capture_event | Captures an event on the currently active client if any. |
capture_message | Captures an arbitrary message. |
configure_scope | Invokes a function that can modify the current scope. |
event_from_error | Create a sentry |
init | Creates the Sentry client for a given client config and binds it. |
last_event_id | Returns the last event ID captured. |
parse_type_from_debug | Parse the types name from |
with_integration | Looks up an integration on the current Hub. |
with_scope | Temporarily pushes a scope for a single call optionally reconfiguring it. |