Struct Event

pub struct Event<'a> { /* private fields */ }

Events represent single points in time where something occurred during the execution of a program.

An Event can be compared to a log record in unstructured logging, but with two key differences:

Implementations

impl<'a> Event<'a>

fn dispatch(metadata: &'static Metadata<'static>, fields: &'a ValueSet<'_>)

Constructs a new Event with the specified metadata and set of values, and observes it with the current subscriber.

fn new(metadata: &'static Metadata<'static>, fields: &'a ValueSet<'a>) -> Self

Returns a new Event in the current span, with the specified metadata and set of values.

fn new_child_of(parent: impl Into<Option<Id>>, metadata: &'static Metadata<'static>, fields: &'a ValueSet<'a>) -> Self

Returns a new Event as a child of the specified span, with the provided metadata and set of values.

fn child_of(parent: impl Into<Option<Id>>, metadata: &'static Metadata<'static>, fields: &'a ValueSet<'_>)

Constructs a new Event with the specified metadata and set of values, and observes it with the current subscriber and an explicit parent.

fn record(&self, visitor: &mut dyn Visit)

Visits all the fields on this Event with the specified visitor.

fn fields(&self) -> Iter

Returns an iterator over the set of values on this Event.

fn metadata(&self) -> &'static Metadata<'static>

Returns metadata describing this Event.

fn is_root(&self) -> bool

Returns true if the new event should be a root.

fn is_contextual(&self) -> bool

Returns true if the new event's parent should be determined based on the current context.

If this is true and the current thread is currently inside a span, then that span should be the new event's parent. Otherwise, if the current thread is not inside a span, then the new event will be the root of its own trace tree.

fn parent(&self) -> Option<&Id>

Returns the new event's explicitly-specified parent, if there is one.

Otherwise (if the new event is a root or is a child of the current span), returns None.

Trait Implementations

impl<'a> Debug for Event<'a>

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

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Event<'a>

impl<'a> !Send for Event<'a>

impl<'a> !Sync for Event<'a>

impl<'a> !UnwindSafe for Event<'a>

impl<'a> Freeze for Event<'a>

impl<'a> Unpin for Event<'a>

impl<'a> UnsafeUnpin for Event<'a>

Blanket Implementations

impl<T> Any for Event<'a> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Event<'a> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Event<'a> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Event<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for Event<'a> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Event<'a> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Event<'a> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>