pub struct WideEvent { /* private fields */ }Expand description
A wide event that accumulates structured fields over its lifetime.
Field setters are cheap — they only touch a local Mutex<HashMap>,
never the tracing subscriber stack.
Implementations§
Source§impl WideEvent
impl WideEvent
Sourcepub fn new(subsystem: &'static str) -> Self
pub fn new(subsystem: &'static str) -> Self
Create a new wide event for the given subsystem.
To set a process-wide "system" field, configure it on the
WideEventLayer via WideEventLayer::with_system.
Sourcepub fn set_emit_hook(&self, hook: EmitHook)
pub fn set_emit_hook(&self, hook: EmitHook)
Set a hook called with the accumulated fields just before emit.
Sourcepub fn has_key(&self, key: &str) -> bool
pub fn has_key(&self, key: &str) -> bool
Returns true if the given key exists in the accumulated fields.
Sourcepub fn set_str(&self, key: &'static str, val: &str)
pub fn set_str(&self, key: &'static str, val: &str)
Set a string field (copies val; use set_string to move an owned String).
Sourcepub fn set_string(&self, key: &'static str, val: String)
pub fn set_string(&self, key: &'static str, val: String)
Set a string field from an owned String (avoids a copy).
Sourcepub fn set_f64(&self, key: &'static str, val: f64)
pub fn set_f64(&self, key: &'static str, val: f64)
Set a 64-bit floating-point field (NaN / Inf are stored as null).
Sourcepub fn set_value(&self, key: &'static str, val: Value)
pub fn set_value(&self, key: &'static str, val: Value)
Set a field from a raw serde_json::Value.
Sourcepub fn incr(&self, key: &'static str)
pub fn incr(&self, key: &'static str)
Increment an integer counter field by 1 (initialized to 1 if absent).
Sourcepub fn set_error(&self, err_type: &str, message: &str)
pub fn set_error(&self, err_type: &str, message: &str)
Set error = true, error.type, and error.message.
Sourcepub fn emit(&self)
pub fn emit(&self)
Emit the wide event through the tracing pipeline.
The tracing target is {target_prefix}::{subsystem} where
target_prefix defaults to wide_event. Configure the prefix
on WideEventLayer::with_target_prefix.
Calling emit() more than once is a no-op.