Crate ckb_sentry

Crate ckb_sentry 

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

Additional features:

  • anyhow: Enables support for the anyhow crate.
  • debug-images: Attaches a list of loaded libraries to events (currently only supported on unix).
  • error-chain: Enables support for the error-chain crate.
  • failure: Enables support for the failure crate.
  • log: Enables support for the log crate.
  • env_logger: Enables support for the log crate with additional env_logger support.
  • slog: Enables support for the slog crate.
  • test: Enables testing support.
  • debug-logs: Uses the log crate for internal logging.
  • reqwest: Enables the reqwest transport, which is currently the default.
  • curl: Enables the curl transport.
  • surf: Enables the surf transport.
  • native-tls: Uses the native-tls crate, which is currently the default. This only has an effect on the reqwest transport.
  • rustls: Enables the rustls support of the reqwest transport. Please note that native-tls is a default feature, and one needs to use default-features = false to completely disable building native-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.
ClientInitGuard
Helper struct that is returned from init.
ClientOptions
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.
ScopeGuard
A scope guard.
SentryFuture
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.
IntoBreadcrumbs
A helper trait that converts self into an Iterator of Breadcrumbs.
IntoDsn
Helper trait to convert a string into an Option<Dsn>.
SentryFutureExt
Future extensions for Sentry.
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 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 a std::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.