Struct Metadata
struct Metadata<'a> { ... }
Metadata describing a span or event.
All spans and events have the following metadata:
- A name, represented as a static string.
- A target, a string that categorizes part of the system where the span
or event occurred. The
tracingmacros default to using the module path where the span or event originated as the target, but it may be overridden. - A verbosity level. This determines how verbose a given span or event
is, and allows enabling or disabling more verbose diagnostics
situationally. See the documentation for the
Leveltype for details. - The names of the fields defined by the span or event.
- Whether the metadata corresponds to a span or event.
In addition, the following optional metadata describing the source code location where the span or event originated may be provided:
- The file name
- The line number
- The module path
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) -> SelfConstruct new metadata for a span or event, with a name, target, level, field names, and optional source code location.
fn fields(self: &Self) -> &FieldSetReturns the names of the fields on the described span or event.
fn level(self: &Self) -> &LevelReturns the level of verbosity of the described span or event.
fn name(self: &Self) -> &'static strReturns the name of the span.
fn target(self: &Self) -> &'a strReturns 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
Noneif 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
Noneif the file is unknownfn line(self: &Self) -> Option<u32>Returns the line number in the source code file where the span occurred, or
Noneif the line number is unknown.fn callsite(self: &Self) -> IdentifierReturns an opaque
Identifierthat uniquely identifies the callsite thisMetadataoriginated from.fn is_event(self: &Self) -> boolReturns true if the callsite kind is
Event.fn is_span(self: &Self) -> boolReturn 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) -> TReturns the argument unchanged.
impl<T, U> Into for Metadata<'a>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses 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>