Struct tracing_chrome::ChromeLayerBuilder
source · [−]pub struct ChromeLayerBuilder<S> where
S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync, { /* private fields */ }
Implementations
sourceimpl<S> ChromeLayerBuilder<S> where
S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync,
impl<S> ChromeLayerBuilder<S> where
S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync,
pub fn new() -> Self
sourcepub fn file<P: AsRef<Path>>(self, file: P) -> Self
pub fn file<P: AsRef<Path>>(self, file: P) -> Self
Set the file to which to output the trace.
Defaults to “./trace-{unix epoch time}.json”
sourcepub fn include_args(self, include: bool) -> Self
pub fn include_args(self, include: bool) -> Self
Include arguments in each trace entry.
Defaults to false.
Includes the arguments used when creating a span/event in the “args” section of the trace entry.
sourcepub fn include_locations(self, include: bool) -> Self
pub fn include_locations(self, include: bool) -> Self
Include file+line with each trace entry.
Defaults to true.
This can add quite a bit of data to the output so turning it off might be helpful when collecting larger traces.
sourcepub fn trace_style(self, style: TraceStyle) -> Self
pub fn trace_style(self, style: TraceStyle) -> Self
Sets the style used when recording trace events.
See TraceStyle
for details.
sourcepub fn name_fn(
self,
name_fn: Box<dyn Fn(&EventOrSpan<'_, '_, S>) -> String + Send + Sync>
) -> Self
pub fn name_fn(
self,
name_fn: Box<dyn Fn(&EventOrSpan<'_, '_, S>) -> String + Send + Sync>
) -> Self
Allows supplying a function that derives a name from an Event or Span. The result is used as the “name” field on trace entries.
Example
use tracing_chrome::{ChromeLayerBuilder, EventOrSpan};
use tracing_subscriber::{registry::Registry, prelude::*};
let (chrome_layer, _guard) = ChromeLayerBuilder::new().name_fn(Box::new(|event_or_span| {
match event_or_span {
EventOrSpan::Event(ev) => { ev.metadata().name().into() },
EventOrSpan::Span(_s) => { "span".into() },
}
})).build();
tracing_subscriber::registry().with(chrome_layer).init()
sourcepub fn category_fn(
self,
cat_fn: Box<dyn Fn(&EventOrSpan<'_, '_, S>) -> String + Send + Sync>
) -> Self
pub fn category_fn(
self,
cat_fn: Box<dyn Fn(&EventOrSpan<'_, '_, S>) -> String + Send + Sync>
) -> Self
Allows supplying a function that derives a category from an Event or Span. The result is used as the “cat” field on trace entries.
Example
use tracing_chrome::{ChromeLayerBuilder, EventOrSpan};
use tracing_subscriber::{registry::Registry, prelude::*};
let (chrome_layer, _guard) = ChromeLayerBuilder::new().category_fn(Box::new(|_| {
"my_module".into()
})).build();
tracing_subscriber::registry().with(chrome_layer).init()
pub fn build(self) -> (ChromeLayer<S>, FlushGuard)
Trait Implementations
sourceimpl<S: Default> Default for ChromeLayerBuilder<S> where
S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync,
impl<S: Default> Default for ChromeLayerBuilder<S> where
S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync,
sourcefn default() -> ChromeLayerBuilder<S>
fn default() -> ChromeLayerBuilder<S>
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl<S> !RefUnwindSafe for ChromeLayerBuilder<S>
impl<S> Send for ChromeLayerBuilder<S>
impl<S> Sync for ChromeLayerBuilder<S>
impl<S> Unpin for ChromeLayerBuilder<S> where
S: Unpin,
impl<S> !UnwindSafe for ChromeLayerBuilder<S>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more