Skip to main content

WideEvent

Struct WideEvent 

Source
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

Source

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.

Source

pub fn set_emit_hook(&self, hook: EmitHook)

Set a hook called with the accumulated fields just before emit.

Source

pub fn has_key(&self, key: &str) -> bool

Returns true if the given key exists in the accumulated fields.

Source

pub fn set_str(&self, key: &'static str, val: &str)

Set a string field (copies val; use set_string to move an owned String).

Source

pub fn set_string(&self, key: &'static str, val: String)

Set a string field from an owned String (avoids a copy).

Source

pub fn set_i64(&self, key: &'static str, val: i64)

Set a signed 64-bit integer field.

Source

pub fn set_u64(&self, key: &'static str, val: u64)

Set an unsigned 64-bit integer field.

Source

pub fn set_f64(&self, key: &'static str, val: f64)

Set a 64-bit floating-point field (NaN / Inf are stored as null).

Source

pub fn set_bool(&self, key: &'static str, val: bool)

Set a boolean field.

Source

pub fn set_value(&self, key: &'static str, val: Value)

Set a field from a raw serde_json::Value.

Source

pub fn incr(&self, key: &'static str)

Increment an integer counter field by 1 (initialized to 1 if absent).

Source

pub fn set_error(&self, err_type: &str, message: &str)

Set error = true, error.type, and error.message.

Source

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.

Trait Implementations§

Source§

impl Debug for WideEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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