pub struct Builder<F = NestedFmt, A = fn() -> Result<TcpStream>> { /* private fields */ }
Expand description

Builder to enable forwarding tracing events towards the fluentd server.

Type params

  • F - Attributes formatter, determines how to compose fluent::Record.
  • A - function that returns Fluentd wrter. Default is to create tcp socket towards 127.0.0.1:24224 with timeout of 1s.

Implementations§

source§

impl Builder

source

pub fn new(tag: &'static str) -> Self

Creates default configuration.

Params:

tag - Event category to send for each record.

source

pub fn with_max_msg_record(self, max_msg_record: NonZeroUsize) -> Self

Provides max message record to fetch up.

source§

impl<A: MakeWriter> Builder<NestedFmt, A>

source

pub fn flatten(self) -> Builder<FlattenFmt, A>

Configures to flatten span/metadata attributes within record. Instead of the default nesting behavior.

source§

impl<F: FieldFormatter, A: MakeWriter> Builder<F, A>

source

pub fn with_formatter<NF: FieldFormatter>(self, fmt: NF) -> Builder<NF, A>

Provides formatter.

source

pub fn with_writer<MW: MakeWriter>(self, writer: MW) -> Builder<F, MW>

Provides callback to get writer where to write records.

Normally fluentd server expects connection to be closed immediately upon sending records. hence created writer is dropped immediately upon writing being finished.

source

pub fn layer(self) -> Result<Layer<F, ThreadWorker>, Error>

Creates tracing layer.

If you do not want to create multiple threads, consider using layer_guarded/layer_from_guard.

Error can happen during creation of worker thread.

source

pub fn layer_guarded( self ) -> Result<(Layer<F, WorkerChannel>, FlushingGuard), Error>

Creates tracing layer, returning guard that allows to stop fluentd worker on Drop.

This may be necessary due to bad API that tracing provides to control lifetime of global logger. As underlying implementations employs caching, it needs to perform flush once logger is no longer necessary hence this API is provided.

Error can happen during creation of worker thread.

source

pub fn layer_from_guard(self, guard: &FlushingGuard) -> Layer<F, WorkerChannel>

Creates tracing layer, using guard returned by layer_guarded.

Specifically, it will use the same worker thread as first instance of layer_guarded, without affecting lifetime of guard. Hence once guard is dropped, worker for all connected layers will stop sending logs.

Error can happen during creation of worker thread.

Auto Trait Implementations§

§

impl<F, A> RefUnwindSafe for Builder<F, A>where A: RefUnwindSafe, F: RefUnwindSafe,

§

impl<F, A> Send for Builder<F, A>where A: Send, F: Send,

§

impl<F, A> Sync for Builder<F, A>where A: Sync, F: Sync,

§

impl<F, A> Unpin for Builder<F, A>where A: Unpin, F: Unpin,

§

impl<F, A> UnwindSafe for Builder<F, A>where A: UnwindSafe, F: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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