Expand description

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

The tracing crate is supported in three ways. First, events can be captured as breadcrumbs for later. Secondly, error events can be captured as events to Sentry. Finally, spans can be recorded as structured transaction events. By default, events above Info are recorded as breadcrumbs, events above Error are captured as error events, and spans above Info are recorded as transactions.

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.


use std::time::Duration;

use tokio::time::sleep;
use tracing_subscriber::prelude::*;

async fn main() {
    let _guard = sentry::init(sentry::ClientOptions {
        // Set this a to lower value in production
        traces_sample_rate: 1.0,



// Functions instrumented by tracing automatically report
// their span as transactions
async fn outer() {
    tracing::info!("Generates a breadcrumb");

    for _ in 0..10 {

    tracing::error!("Generates an event");

async fn inner() {
    // 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;
use tracing_subscriber::prelude::*;

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



Provides a tracing layer that dispatches events to sentry


The action that Sentry should perform for a Metadata

The type of data Sentry should ingest for a Event


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

The default event filter.

The default span filter.

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

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

Creates a default Sentry layer