pub struct ECSLayerBuilder { /* private fields */ }
Expand description
Builder for a subscriber Layer writing ECS compatible json lines to a writer.
Example:
use tracing_ecs::ECSLayerBuilder;
// creates a minimal layer logging to stdout, and install it
ECSLayerBuilder::default()
.stdout()
.install()
.unwrap();
Implementations§
Source§impl ECSLayerBuilder
impl ECSLayerBuilder
pub fn with_extra_fields<F: Serialize>( self, extra_fields: F, ) -> Result<Self, Error>
pub fn with_attribute_mapper<M>(self, attribute_mapper: M) -> Selfwhere
M: AttributeMapper,
pub fn with_span_events(self, span_events: FmtSpan) -> Self
Sourcepub fn normalize_json(self, normalize_json: bool) -> Self
pub fn normalize_json(self, normalize_json: bool) -> Self
Control the normalization (keys de-dotting) of the generated json in the sense of https://www.elastic.co/guide/en/ecs/current/ecs-guidelines.html.
By default, normalization is enabled, thus logging host.hostname="localhost"
will output:
{"host":{"hostname": "localhost"}}
With normalization disabled:
{"host.hostname": "localhost"}
Depending on your use case you may want to disable normalization if it’s done elsewhere in your log processing pipeline.
Benchmarks suggests a 30% speed up on log generation. (benches run on an Apple M2 Pro) it will
also allocate less because, normalization recursively recreates a brand new json Value
(not measured).
pub fn stderr(self) -> ECSLayer<fn() -> Stderr>
pub fn stdout(self) -> ECSLayer<fn() -> Stdout>
pub fn build_with_writer<W>(self, writer: W) -> ECSLayer<W>where
W: for<'writer> MakeWriter<'writer> + 'static,
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ECSLayerBuilder
impl !RefUnwindSafe for ECSLayerBuilder
impl Send for ECSLayerBuilder
impl Sync for ECSLayerBuilder
impl Unpin for ECSLayerBuilder
impl !UnwindSafe for ECSLayerBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more