logo
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 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://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.

More complex examples on how to use sentry can also be found in examples. Extended instructions may also be found on Sentry itself.

Integrations

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.

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

Additional functionality and integrations are enabled via feature flags. Some features require extra setup to function properly.

FeatureDefaultIs IntegrationDeprecatedAdditional notes
backtrace🔌
contexts🔌
panic🔌
transport
anyhow🔌
test
debug-images🔌
log🔌Requires extra setup; See sentry-log’s documentation.
debug-logsRequires extra setup; See sentry-log’s documentation.
slog🔌Requires extra setup; See sentry-slog’s documentation.
reqwest
native-tlsreqwest must be enabled.
rustlsreqwest must be enabled. native-tls must be disabled via default-features = false.
curl
surf
tower🔌Requires extra setup; See sentry-tower’s documentation.
urequreq transport support using rustls by default
ureq-native-tls

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 currently reqwest with native-tls.

Debugging/Testing

  • anyhow: Enables support for the anyhow crate.
  • test: Enables testing support.
  • debug-images: Attaches a list of loaded libraries to events (currently only supported on Unix).

Logging

  • log: Enables support for the log crate.
  • slog: Enables support for the slog crate.
  • debug-logs: Deprecated. Uses the log crate for internal logging.

Transports

  • reqwest: Default. Enables the reqwest transport.
  • native-tls: Default. Uses the native-tls crate. This only affects the reqwest transport.
  • rustls: Enables rustls support for reqwest. Please note that native-tls is a default feature, and default-features = false must be set to completely disable building native-tls dependencies.
  • curl: Enables the curl transport.
  • surf: Enables the surf transport.
  • ureq: Enables the ureq transport using rustls.
  • ureq-native-tls: Enables the ureq transport using native-tls.

Integrations

  • tower: Enables support for the tower crate and those using it.

Modules

Available Sentry Integrations.

The current latest sentry protocol version.

This provides testing functionality for building tests.

The provided transports.

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

Returns the intended release for Sentry as an Option<Cow<'static, str>>.

Structs

Represents a single breadcrumb.

The Sentry Client.

Helper struct that is returned from init.

Configuration settings for the client.

A Sentry Envelope.

The central object that can manages scopes and clients.

Holds contextual data for the current scope.

A scope guard.

A future that binds a Hub to its execution.

A running Performance Monitoring Span.

An Iterator over HTTP header names and values needed for distributed tracing.

A running Performance Monitoring Transaction.

The Transaction Context used to start a new Performance Monitoring Transaction.

Represents user info.

Enums

Represents the level of severity of an event or breadcrumb.

The Session Mode of the SDK.

A wrapper that groups a Transaction and a Span together.

Traits

Integration abstraction.

A helper trait that converts self into an Iterator of Breadcrumbs.

Helper trait to convert a string into an Option<Dsn>.

Future extensions for Sentry.

The trait for transports.

A factory creating transport instances.

Functions

Records a breadcrumb by calling a function.

Apply default client options.

Captures a std::error::Error.

Captures an event on the currently active client if any.

Captures an arbitrary message.

Invokes a function that can modify the current scope.

End the current Release Health Session.

End the current Release Health Session with the given SessionStatus.

Create a sentry Event from a std::error::Error.

Creates the Sentry client for a given client config and binds it.

Returns the last event ID captured.

Parse the types name from Debug output.

Start a new session for Release Health.

Start a new Performance Monitoring Transaction.

Looks up an integration on the current Hub.

Temporarily pushes a scope for a single call optionally reconfiguring it.