Struct Metadata

struct Metadata<'a> { ... }

Metadata describing a span or event.

All spans and events have the following metadata:

In addition, the following optional metadata describing the source code location where the span or event originated may be provided:

Metadata is used by Subscribers when filtering spans and events, and it may also be used as part of their data payload.

When created by the event! or span! macro, the metadata describing a particular event or span is constructed statically and exists as a single static instance. Thus, the overhead of creating the metadata is significantly lower than that of creating the actual span. Therefore, filtering is based on metadata, rather than on the constructed span.

Equality

In well-behaved applications, two Metadata with equal callsite identifiers will be equal in all other ways (i.e., have the same name, target, etc.). Consequently, in release builds, Metadata::eq only checks that its arguments have equal callsites. However, the equality of Metadata's other fields is checked in debug builds.

Implementations

impl<'a> Metadata<'a>

const fn new(name: &'static str, target: &'a str, level: Level, file: Option<&'a str>, line: Option<u32>, module_path: Option<&'a str>, fields: FieldSet, kind: Kind) -> Self

Construct new metadata for a span or event, with a name, target, level, field names, and optional source code location.

fn fields(self: &Self) -> &FieldSet

Returns the names of the fields on the described span or event.

fn level(self: &Self) -> &Level

Returns the level of verbosity of the described span or event.

fn name(self: &Self) -> &'static str

Returns the name of the span.

fn target(self: &Self) -> &'a str

Returns a string describing the part of the system where the span or event that this metadata describes occurred.

Typically, this is the module path, but alternate targets may be set when spans or events are constructed.

fn module_path(self: &Self) -> Option<&'a str>

Returns the path to the Rust module where the span occurred, or None if the module path is unknown.

fn file(self: &Self) -> Option<&'a str>

Returns the name of the source code file where the span occurred, or None if the file is unknown

fn line(self: &Self) -> Option<u32>

Returns the line number in the source code file where the span occurred, or None if the line number is unknown.

fn callsite(self: &Self) -> Identifier

Returns an opaque Identifier that uniquely identifies the callsite this Metadata originated from.

fn is_event(self: &Self) -> bool

Returns true if the callsite kind is Event.

fn is_span(self: &Self) -> bool

Return true if the callsite kind is Span.

impl Debug for Metadata<'_>

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

impl Eq for Metadata<'_>

impl PartialEq for Metadata<'_>

fn eq(self: &Self, other: &Self) -> bool

impl<'a> Freeze for Metadata<'a>

impl<'a> RefUnwindSafe for Metadata<'a>

impl<'a> Send for Metadata<'a>

impl<'a> Sync for Metadata<'a>

impl<'a> Unpin for Metadata<'a>

impl<'a> UnsafeUnpin for Metadata<'a>

impl<'a> UnwindSafe for Metadata<'a>

impl<T> Any for Metadata<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Metadata<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Metadata<'a>

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

impl<T> From for Metadata<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Metadata<'a>

fn into(self: 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 for Metadata<'a>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Metadata<'a>

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