Expand description
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.
use ckb_sentry as sentry;
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.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.failure
: Enables support for thefailure
crate.log
: Enables support for thelog
crate.env_logger
: Enables support for thelog
crate with additionalenv_logger
support.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. Please note thatnative-tls
is a default feature, and one needs to usedefault-features = false
to completely disable buildingnative-tls
dependencies.
Modules§
- integrations
- Available Sentry Integrations.
- 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
Option<Cow<'static, str>>
.
Structs§
- Breadcrumb
- Represents a single breadcrumb.
- Client
- The Sentry Client.
- Client
Init Guard - Helper struct that is returned from
init
. - Client
Options - Configuration settings for the client.
- Envelope
- A Sentry Envelope.
- Hub
- The central object that can manages scopes and clients.
- Scope
- Holds contextual data for the current scope.
- Scope
Guard - A scope guard.
- Sentry
Future - A future that binds a
Hub
to its execution. - User
- Represents user info.
Enums§
- Level
- Represents the level of severity of an event or breadcrumb.
Traits§
- Integration
- Integration abstraction.
- Into
Breadcrumbs - A helper trait that converts self into an Iterator of Breadcrumbs.
- IntoDsn
- Helper trait to convert a string into an
Option<Dsn>
. - Sentry
Future Ext - Future extensions for Sentry.
- Transport
- The trait for transports.
- Transport
Factory - 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
std::error::Error
. - 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.
- end_
session - End the current Release Health Session.
- end_
session_ with_ status - End the current Release Health Session with the given
SessionStatus
. - event_
from_ error - Create a sentry
Event
from astd::error::Error
. - 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
Debug
output. - start_
session - Start a new session for Release Health.
- with_
integration - Looks up an integration on the current Hub.
- with_
scope - Temporarily pushes a scope for a single call optionally reconfiguring it.