Struct tracing_fluentd::Builder
source · 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 composefluent::Record
.A
- function that returnsFluentd
wrter. Default is to create tcp socket towards127.0.0.1:24224
with timeout of 1s.
Implementations§
source§impl Builder
impl Builder
sourcepub fn with_max_msg_record(self, max_msg_record: NonZeroUsize) -> Self
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>
impl<A: MakeWriter> Builder<NestedFmt, A>
sourcepub fn flatten(self) -> Builder<FlattenFmt, A>
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>
impl<F: FieldFormatter, A: MakeWriter> Builder<F, A>
sourcepub fn with_formatter<NF: FieldFormatter>(self, fmt: NF) -> Builder<NF, A>
pub fn with_formatter<NF: FieldFormatter>(self, fmt: NF) -> Builder<NF, A>
Provides formatter.
sourcepub fn with_writer<MW: MakeWriter>(self, writer: MW) -> Builder<F, MW>
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.
sourcepub fn layer(self) -> Result<Layer<F, ThreadWorker>, Error>
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.
sourcepub fn layer_guarded(
self
) -> Result<(Layer<F, WorkerChannel>, FlushingGuard), Error>
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.
sourcepub fn layer_from_guard(self, guard: &FlushingGuard) -> Layer<F, WorkerChannel>
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.