pub struct WideEventGuard(/* private fields */);Expand description
RAII guard that emits the wide event when dropped.
Implements Deref<Target = WideEvent> so you can call setters directly.
let req = WideEventGuard::new("http");
req.set_str("method", "GET");
req.set_u64("status", 200);
// emitted automatically when `req` dropsImplementations§
Methods from Deref<Target = WideEvent>§
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.