#[non_exhaustive]pub struct SpanLayer {}Expand description
Captures tracing spans as Sentry transactions and spans.
Install this layer to capture spans; event layers do not manage the span lifecycle.
Without a filter, this layer captures spans at every level. Configure a filter to limit span
volume; see SpanLayer::new for the recommended levels.
Using this layer alongside the legacy SentryLayer is unsupported.
Combining the two layers can panic when a span is created. Use either the legacy layer
or the individual layers, not both.
Implementations§
Source§impl SpanLayer
impl SpanLayer
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a layer that captures tracing spans as Sentry transactions and spans.
§Filtering
Without a filter, this layer captures spans at every level. Configure a level filter to limit
span volume. We recommend capturing spans at the INFO level, and more severe.
use sentry::integrations::tracing::SpanLayer;
use tracing_subscriber::filter::LevelFilter;
tracing_subscriber::registry()
.with(SpanLayer::new().with_filter(LevelFilter::INFO))
.init();
// This will be captured ...
let _info = tracing::info_span!("INFO span").entered();
// ... but this will not be, due to LevelFilter::INFO being set.
let _debug = tracing::debug_span!("DEBUG span").entered();Trait Implementations§
Source§impl<S> Layer<S> for SpanLayerwhere
S: Subscriber + for<'a> LookupSpan<'a>,
impl<S> Layer<S> for SpanLayerwhere
S: Subscriber + for<'a> LookupSpan<'a>,
Source§fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>)
fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>)
When a new Span gets created, start a new sentry span, setting it as the current sentry span.
Source§fn on_enter(&self, id: &Id, ctx: Context<'_, S>)
fn on_enter(&self, id: &Id, ctx: Context<'_, S>)
Sets the entered span as current sentry span.
A tracing span can be entered and exited multiple times, for example,
when using a tracing::Instrumented future.
Spans must be exited on the same thread that they are entered. The
sentry-tracing integration’s behavior is undefined if spans are
exited on threads other than the one they are entered from;
specifically, doing so will likely cause data to bleed between
Hubs in unexpected ways.
Source§fn on_exit(&self, id: &Id, ctx: Context<'_, S>)
fn on_exit(&self, id: &Id, ctx: Context<'_, S>)
Drop the current span’s HubSwitchGuard to restore the parent Hub.
Source§fn on_close(&self, id: Id, ctx: Context<'_, S>)
fn on_close(&self, id: Id, ctx: Context<'_, S>)
Finish the underlying sentry span when the tracing span closes.
Source§fn on_record(&self, span: &Id, values: &Record<'_>, ctx: Context<'_, S>)
fn on_record(&self, span: &Id, values: &Record<'_>, ctx: Context<'_, S>)
Implement the writing of extra data to span.
Source§fn on_register_dispatch(&self, subscriber: &Dispatch)
fn on_register_dispatch(&self, subscriber: &Dispatch)
Subscriber. Read moreSource§fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
Subscriber::register_callsite. Read moreSource§fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool
fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool
true if this layer is interested in a span or event with the
given metadata in the current Context, similarly to
Subscriber::enabled. Read moreSource§fn on_follows_from(&self, _span: &Id, _follows: &Id, _ctx: Context<'_, S>)
fn on_follows_from(&self, _span: &Id, _follows: &Id, _ctx: Context<'_, S>)
span recorded that it
follows from the span with the ID follows.Source§fn on_event(&self, _event: &Event<'_>, _ctx: Context<'_, S>)
fn on_event(&self, _event: &Event<'_>, _ctx: Context<'_, S>)
Source§fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<'_, S>)
fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<'_, S>)
Source§fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
Layer, returning a Layered
struct implementing Layer. Read moreSource§fn with_subscriber(self, inner: S) -> Layered<Self, S>where
Self: Sized,
fn with_subscriber(self, inner: S) -> Layered<Self, S>where
Self: Sized,
Layer with the given Subscriber, returning a
Layered struct that implements Subscriber. Read more