Struct SubscriberBuilder

Source
pub struct SubscriberBuilder { /* private fields */ }
Expand description

Builder for the trace_tools subscriber.

This can be used to enable/disable Layers provided by this crate.

Implementations§

Source§

impl SubscriberBuilder

Source

pub fn with_log_layer(self, logger_config: LoggerConfig) -> Self

Enables the LogLayer for this subscriber, using the parameters provided by the given LoggerConfig.

Source

pub fn with_default_log_layer(self) -> Self

Enables the LogLayer for this subscriber, using the default configuration.

Source

pub fn with_flamegraph_layer<P: AsRef<Path>>(self, folded_stack_file: P) -> Self

Enables the FlamegraphLayer for this subscriber.

The given path describes the desired output location of the folded stack file that is generated by this layer during runtime. This file can then be used to produce a flamegraph by a Flamegrapher instance, or by the inferno tool.

Source

pub fn finish(self) -> Result<(TraceSubscriber, Option<Flamegrapher>), Error>

Builds and returns the TraceSubscriber.

§Errors
§Notes
  • This method calls the collect_logs function. Any log records emitted will be converting into tracing events, and therefore any external functionality that deals with log records may no longer function as expected.
  • This method does not set the global subscriber. As such, a call to finish can be used to further extend the return subscriber with external Layers.
Source

pub fn init(self) -> Result<Option<Flamegrapher>, Error>

Builds the TraceSubscriber and sets it as the global default subscriber.

Returns a Result over an Option<Flamegrapher>. The returned option is Some if the LogLayer is enabled and has been successfully initialised. If the `LogLayer has not been enabled with the builder, it is fine to ignore this value.

§Errors
§Panics

This method will panic if the flamegraph layer is enabled and the program is not built with --cfg tokio_unstable.

§Notes
  • This method calls the collect_logs function. Any log records emitted will be converting into tracing events, and therefore any external functionality that deals with log records may no longer function as expected.
  • This method sets the global subscriber. Any further attempts to set the global subscriber (including another call to this method) will fail.
  • The subscriber initialised by this method cannot be extended.

Trait Implementations§

Source§

impl Default for SubscriberBuilder

Source§

fn default() -> SubscriberBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Observe for T
where T: Instrument,

Source§

fn observe(self, name: &str) -> Instrumented<T>

Instruments Self with a tracing span, returning Instrumented<Self>.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more