Struct LayerBuilder

Source
pub struct LayerBuilder<Mode>
where Mode: ProviderTypes,
{ /* private fields */ }
Expand description

Builds a tracing_subscriber::Layer that will logs events from a single ETW or user_events provider. Use LayerBuilder::new to construct a new builder for the given provider name. Use the with_* methods to set additional properties for the provider, such as the keyword to use for events (default: 1) or a specific provider GUID (default: a hash of the provider name).

Use LayerBuilder::new_common_schema_events to create a layer that will log events in the Common Schema 4.0 mapping. Only use this if you know that you need events in this format.

Multiple tracing_etw layers can be created at the same time, with different provider names/IDs, keywords, or output formats. (Target filters)tracing_subscriber::filter can then be used to direct specific events to specific layers.

Implementations§

Source§

impl LayerBuilder<Provider>

Source

pub fn new(name: &str) -> LayerBuilder<Provider>

Source§

impl LayerBuilder<CommonSchemaProvider>

Source

pub fn new_common_schema_events( name: &str, ) -> LayerBuilder<CommonSchemaProvider>

For advanced scenarios. Emit events that follow the Common Schema 4.0 mapping. Recommended only for compatibility with specialized event consumers. Most ETW consumers will not benefit from events in this schema, and may perform worse. Common Schema events are much slower to generate and should not be enabled unless absolutely necessary.

Source§

impl<Mode> LayerBuilder<Mode>
where Mode: ProviderTypes + 'static,

Source

pub fn with_provider_id<G>(self, guid: &G) -> Self
where for<'a> &'a G: Into<GuidWrapper>,

For advanced scenarios. Assign a provider ID to the ETW provider rather than use one generated from the provider name.

Source

pub fn get_provider_id(&self) -> GuidWrapper

Get the current provider ID that will be used for the ETW provider. This is a convenience function to help with tools that do not implement the standard provider name to ID algorithm.

Source

pub fn with_default_keyword(self, kw: u64) -> Self

Set the keyword used for events that do not explicitly set a keyword.

Events logged with the crate::etw_event! macro specify a keyword for the event. Events and spans logged with the tracing::event!, tracing::span!, or other similar tracing macros will use the default keyword.

If this method is not called, the default keyword will be 1.

Keyword value 0 is special in ETW (but not user_events), and should not be used.

Source

pub fn with_provider_group<G>(self, group_id: &G) -> Self
where for<'a> &'a G: Into<Mode::ProviderGroupType>,

For advanced scenarios. Set the provider group to join this provider to.

Source

pub fn build_global_filter<S>(self) -> Result<EtwLayer<S, Mode>, EtwError>
where S: Subscriber + for<'a> LookupSpan<'a>, Mode::Provider: EventWriter<Mode> + 'static,

Available on crate feature global_filter only.
Source

pub fn build<S>( self, ) -> Result<Filtered<EtwLayer<S, Mode>, EtwFilter<S, Mode>, S>, EtwError>
where S: Subscriber + for<'a> LookupSpan<'a>, Mode::Provider: EventWriter<Mode> + 'static,

Available on non-crate feature global_filter only.
Source

pub fn build_with_target<S>( self, target: &'static str, ) -> Result<Filtered<EtwLayer<S, Mode>, And<EtwFilter<S, Mode>, Targets, S>, S>, EtwError>
where S: Subscriber + for<'a> LookupSpan<'a>, Mode::Provider: EventWriter<Mode> + 'static,

Available on non-crate feature global_filter only.

Constructs the configured layer with a target tracing_subscriber::filter applied. This can be used to target specific events to specific layers, and in effect allow specific events to be logged only from specific ETW/user_event providers.

Auto Trait Implementations§

§

impl<Mode> Freeze for LayerBuilder<Mode>
where <Mode as ProviderTypes>::ProviderGroupType: Freeze,

§

impl<Mode> RefUnwindSafe for LayerBuilder<Mode>
where <Mode as ProviderTypes>::ProviderGroupType: RefUnwindSafe, Mode: RefUnwindSafe,

§

impl<Mode> Send for LayerBuilder<Mode>
where <Mode as ProviderTypes>::ProviderGroupType: Send, Mode: Send,

§

impl<Mode> Sync for LayerBuilder<Mode>
where <Mode as ProviderTypes>::ProviderGroupType: Sync, Mode: Sync,

§

impl<Mode> Unpin for LayerBuilder<Mode>
where <Mode as ProviderTypes>::ProviderGroupType: Unpin, Mode: Unpin,

§

impl<Mode> UnwindSafe for LayerBuilder<Mode>
where <Mode as ProviderTypes>::ProviderGroupType: UnwindSafe, Mode: UnwindSafe,

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, 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, 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