Crate sentry_tracing[][src]

Expand description

Adds support for automatic Breadcrumb and Event capturing from tracing events, similar to the sentry-log crate.

The tracing crate is supported in two ways. First, events can be captured as breadcrumbs for later. Secondly, error events can be captured as events to Sentry. By default, anything above Info is recorded as breadcrumb and anything above Error is captured as error event.

By using this crate in combination with tracing-subscriber and its log integration, sentry-log does not need to be used, as logs will be ingested in the tracing system and generate events, thus be relayed to this crate. It effectively replaces sentry-log when tracing is used.

Examples

use tracing_subscriber::prelude::*;

tracing_subscriber::registry()
    .with(tracing_subscriber::fmt::layer())
    .with(sentry_tracing::layer())
    .try_init()
    .unwrap();

let _sentry = sentry::init(());

tracing::info!("Generates a breadcrumb");
tracing::error!("Generates an event");
// Also works, since log events are ingested by the tracing system
log::info!("Generates a breadcrumb");
log::error!("Generates an event");

Or one might also set an explicit filter, to customize how to treat log records:

use sentry_tracing::EventFilter;

let layer = sentry_tracing::layer().filter(|md| match md.level() {
    &tracing::Level::ERROR => EventFilter::Event,
    _ => EventFilter::Ignore,
});

Structs

Provides a tracing layer that dispatches events to sentry

Enums

The action that Sentry should perform for a Metadata

The type of data Sentry should ingest for a Event

Functions

Creates a [Breadcrumb] from a given tracing_core::Event

Converts a tracing_core::Level to a Sentry [Level]

The default event filter.

Creates an [Event] from a given tracing_core::Event

Creates an exception [Event] from a given tracing_core::Event

Extracts the message and metadata from an event

Creates a default Sentry layer