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>
impl LayerBuilder<Provider>
pub fn new(name: &str) -> LayerBuilder<Provider>
Source§impl LayerBuilder<CommonSchemaProvider>
impl LayerBuilder<CommonSchemaProvider>
Sourcepub fn new_common_schema_events(
name: &str,
) -> LayerBuilder<CommonSchemaProvider>
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,
impl<Mode> LayerBuilder<Mode>where
Mode: ProviderTypes + 'static,
Sourcepub fn with_provider_id<G>(self, guid: &G) -> Self
pub fn with_provider_id<G>(self, guid: &G) -> Self
For advanced scenarios. Assign a provider ID to the ETW provider rather than use one generated from the provider name.
Sourcepub fn get_provider_id(&self) -> GuidWrapper
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.
Sourcepub fn with_default_keyword(self, kw: u64) -> Self
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.
Sourcepub fn with_provider_group<G>(self, group_id: &G) -> Self
pub fn with_provider_group<G>(self, group_id: &G) -> Self
For advanced scenarios. Set the provider group to join this provider to.
pub fn build_global_filter<S>(self) -> Result<EtwLayer<S, Mode>, EtwError>where
S: Subscriber + for<'a> LookupSpan<'a>,
Mode::Provider: EventWriter<Mode> + 'static,
global_filter
only.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,
global_filter
only.Sourcepub 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.
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,
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.