mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
trace-core: Debreak RustDoc links (#961)
This commit fixes a bunch of broken links in the `tokio-trace-core` API docs. Refs: #957
This commit is contained in:
parent
d88aba8d1c
commit
7f911b6b70
@ -32,25 +32,27 @@ pub trait Callsite: Sync {
|
||||
/// If the interest is greater than or equal to the callsite's current
|
||||
/// interest, this should change whether or not the callsite is enabled.
|
||||
///
|
||||
/// [`Interest`]: ::subscriber::Interest
|
||||
/// [registering]: ::subscriber::Subscriber::register_callsite
|
||||
/// [dispatcher]: ::Dispatch
|
||||
/// [`Interest`]: ../subscriber/struct.Interest.html
|
||||
/// [registering]: ../subscriber/trait.Subscriber.html#method.register_callsite
|
||||
/// [dispatcher]: ../dispatcher/struct.Dispatch.html
|
||||
fn add_interest(&self, interest: Interest);
|
||||
|
||||
/// Remove _all_ [`Interest`] from the callsite, disabling it.
|
||||
///
|
||||
/// [`Interest`]: ::subscriber::Interest
|
||||
/// [`Interest`]: ../subscriber/struct.Interest.html
|
||||
fn clear_interest(&self);
|
||||
|
||||
/// Returns the [metadata] associated with the callsite.
|
||||
///
|
||||
/// [metadata]: ::Metadata
|
||||
/// [metadata]: ../metadata/struct.Metadata.html
|
||||
fn metadata(&self) -> &Metadata;
|
||||
}
|
||||
|
||||
/// Uniquely identifies a [`Callsite`](::callsite::Callsite).
|
||||
/// Uniquely identifies a [`Callsite`]
|
||||
///
|
||||
/// Two `Identifier`s are equal if they both refer to the same callsite.
|
||||
///
|
||||
/// [`Callsite`]: ../callsite/trait.Callsite.html
|
||||
#[derive(Clone)]
|
||||
pub struct Identifier(
|
||||
/// **Warning**: The fields on this type are currently `pub` because it must
|
||||
|
@ -11,7 +11,9 @@ use std::{
|
||||
sync::{Arc, Weak},
|
||||
};
|
||||
|
||||
/// `Dispatch` trace data to a [`Subscriber`](::Subscriber).
|
||||
/// `Dispatch` trace data to a [`Subscriber`].
|
||||
///
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
#[derive(Clone)]
|
||||
pub struct Dispatch {
|
||||
subscriber: Arc<Subscriber + Send + Sync>,
|
||||
@ -29,8 +31,8 @@ thread_local! {
|
||||
/// tagged that span, instead.
|
||||
///
|
||||
/// [span]: ../span/index.html
|
||||
/// [`Subscriber`]: ::Subscriber
|
||||
/// [`Event`]: ::Event
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`Event`]: ../event/struct.Event.html
|
||||
pub fn with_default<T>(dispatcher: Dispatch, f: impl FnOnce() -> T) -> T {
|
||||
// A drop guard that resets CURRENT_DISPATCH to the prior dispatcher.
|
||||
// Using this (rather than simply resetting after calling `f`) ensures
|
||||
@ -51,7 +53,9 @@ pub fn with_default<T>(dispatcher: Dispatch, f: impl FnOnce() -> T) -> T {
|
||||
f()
|
||||
}
|
||||
|
||||
/// Executes a closure with a reference to this thread's current dispatcher.
|
||||
/// Executes a closure with a reference to this thread's current [dispatcher].
|
||||
///
|
||||
/// [dispatcher]: ../dispatcher/struct.Dispatch.html
|
||||
pub fn with<T, F>(mut f: F) -> T
|
||||
where
|
||||
F: FnMut(&Dispatch) -> T,
|
||||
@ -71,7 +75,9 @@ impl Dispatch {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a `Dispatch` to the given [`Subscriber`](::Subscriber).
|
||||
/// Returns a `Dispatch` that forwards to the given [`Subscriber`].
|
||||
///
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
pub fn new<S>(subscriber: S) -> Self
|
||||
where
|
||||
S: Subscriber + Send + Sync + 'static,
|
||||
@ -90,39 +96,50 @@ impl Dispatch {
|
||||
/// Registers a new callsite with this subscriber, returning whether or not
|
||||
/// the subscriber is interested in being notified about the callsite.
|
||||
///
|
||||
/// This calls the [`register_callsite`](::Subscriber::register_callsite)
|
||||
/// function on the `Subscriber` that this `Dispatch` forwards to.
|
||||
/// This calls the [`register_callsite`] function on the [`Subscriber`]
|
||||
/// that this `Dispatch` forwards to.
|
||||
///
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`register_callsite`]: ../subscriber/trait.Subscriber.html#method.register_callsite
|
||||
#[inline]
|
||||
pub fn register_callsite(&self, metadata: &Metadata) -> subscriber::Interest {
|
||||
self.subscriber.register_callsite(metadata)
|
||||
}
|
||||
|
||||
/// Visit the construction of a new span, returning a new [ID] for the
|
||||
/// Record the construction of a new span, returning a new [ID] for the
|
||||
/// span being constructed.
|
||||
///
|
||||
/// This calls the [`new_span`](::Subscriber::new_span)
|
||||
/// function on the `Subscriber` that this `Dispatch` forwards to.
|
||||
/// This calls the [`new_span`] function on the [`Subscriber`] that this
|
||||
/// `Dispatch` forwards to.
|
||||
///
|
||||
/// [ID]: ../span/struct.Id.html
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
|
||||
#[inline]
|
||||
pub fn new_span(&self, span: &span::Attributes) -> span::Id {
|
||||
self.subscriber.new_span(span)
|
||||
}
|
||||
|
||||
/// Visit a set of values on a span.
|
||||
/// Record a set of values on a span.
|
||||
///
|
||||
/// This calls the [`record`](::Subscriber::record)
|
||||
/// function on the `Subscriber` that this `Dispatch` forwards to.
|
||||
/// This calls the [`record`] function on the [`Subscriber`] that this
|
||||
/// `Dispatch` forwards to.
|
||||
///
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`record`]: ../subscriber/trait.Subscriber.html#method.record
|
||||
#[inline]
|
||||
pub fn record(&self, span: &span::Id, values: &span::Record) {
|
||||
self.subscriber.record(span, &values)
|
||||
self.subscriber.record(span, values)
|
||||
}
|
||||
|
||||
/// Adds an indication that `span` follows from the span with the id
|
||||
/// `follows`.
|
||||
///
|
||||
/// This calls the [`record_follows_from`](::Subscriber::record_follows_from)
|
||||
/// function on the `Subscriber` that this `Dispatch` forwards to.
|
||||
/// This calls the [`record_follows_from`] function on the [`Subscriber`]
|
||||
/// that this `Dispatch` forwards to.
|
||||
///
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`record_follows_from`]: ../subscriber/trait.Subscriber.html#method.record_follows_from
|
||||
#[inline]
|
||||
pub fn record_follows_from(&self, span: &span::Id, follows: &span::Id) {
|
||||
self.subscriber.record_follows_from(span, follows)
|
||||
@ -131,36 +148,43 @@ impl Dispatch {
|
||||
/// Returns true if a span with the specified [metadata] would be
|
||||
/// recorded.
|
||||
///
|
||||
/// This calls the [`enabled`](::Subscriber::enabled) function on
|
||||
/// the `Subscriber` that this `Dispatch` forwards to.
|
||||
/// This calls the [`enabled`] function on the [`Subscriber`] that this
|
||||
/// `Dispatch` forwards to.
|
||||
///
|
||||
/// [metadata]: ::Metadata
|
||||
/// [metadata]: ../metadata/struct.Metadata.html
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`enabled`]: ../subscriber/trait.Subscriber.html#method.enabled
|
||||
#[inline]
|
||||
pub fn enabled(&self, metadata: &Metadata) -> bool {
|
||||
self.subscriber.enabled(metadata)
|
||||
}
|
||||
|
||||
/// Visits that an [`Event`] has occurred.
|
||||
/// Records that an [`Event`] has occurred.
|
||||
///
|
||||
/// This calls the [`event`](::Subscriber::event) function on
|
||||
/// the `Subscriber` that this `Dispatch` forwards to.
|
||||
/// This calls the [`event`] function on the [`Subscriber`] that this
|
||||
/// `Dispatch` forwards to.
|
||||
///
|
||||
/// [`Event`]: ::event::Event
|
||||
/// [`Event`]: ../event/struct.Event.html
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`event`]: ../subscriber/trait.Subscriber.html#method.event
|
||||
#[inline]
|
||||
pub fn event(&self, event: &Event) {
|
||||
self.subscriber.event(event)
|
||||
}
|
||||
|
||||
/// Visits that a span has been entered.
|
||||
/// Records that a span has been entered.
|
||||
///
|
||||
/// This calls the [`enter`](::Subscriber::enter) function on the
|
||||
/// `Subscriber` that this `Dispatch` forwards to.
|
||||
/// This calls the [`enter`] function on the [`Subscriber`] that this
|
||||
/// `Dispatch` forwards to.
|
||||
///
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`event`]: ../subscriber/trait.Subscriber.html#method.event
|
||||
#[inline]
|
||||
pub fn enter(&self, span: &span::Id) {
|
||||
self.subscriber.enter(span)
|
||||
}
|
||||
|
||||
/// Visits that a span has been exited.
|
||||
/// Records that a span has been exited.
|
||||
///
|
||||
/// This calls the [`exit`](::Subscriber::exit) function on the `Subscriber`
|
||||
/// that this `Dispatch` forwards to.
|
||||
@ -172,26 +196,32 @@ impl Dispatch {
|
||||
/// Notifies the subscriber that a [span ID] has been cloned.
|
||||
///
|
||||
/// This function is guaranteed to only be called with span IDs that were
|
||||
/// returned by this `Dispatch`'s `new_span` function.
|
||||
/// returned by this `Dispatch`'s [`new_span`] function.
|
||||
///
|
||||
/// This calls the [`clone_span`](::Subscriber::clone_span) function on
|
||||
/// the `Subscriber` that this `Dispatch` forwards to.
|
||||
/// This calls the [`clone_span`] function on the `Subscriber` that this
|
||||
/// `Dispatch` forwards to.
|
||||
///
|
||||
/// [span ID]: ../span/struct.Id.html
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`clone_span`]: ../subscriber/trait.Subscriber.html#method.clone_span
|
||||
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
|
||||
#[inline]
|
||||
pub fn clone_span(&self, id: &span::Id) -> span::Id {
|
||||
self.subscriber.clone_span(&id)
|
||||
}
|
||||
|
||||
/// Notifies the subscriber that a [span ID] handle has been dropped.
|
||||
/// Notifies the subscriber that a [span ID] has been dropped.
|
||||
///
|
||||
/// This function is guaranteed to only be called with span IDs that were
|
||||
/// returned by this `Dispatch`'s `new_span` function.
|
||||
/// returned by this `Dispatch`'s [`new_span`] function.
|
||||
///
|
||||
/// This calls the [`drop_span`](::Subscriber::drop_span) function on
|
||||
/// the `Subscriber` that this `Dispatch` forwards to.
|
||||
/// This calls the [`drop_span`] function on the [`Subscriber`] that this
|
||||
/// `Dispatch` forwards to.
|
||||
///
|
||||
/// [span ID]: ../span/struct.Id.html
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`clone_span`]: ../subscriber/trait.Subscriber.html#method.clone_span
|
||||
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
|
||||
#[inline]
|
||||
pub fn drop_span(&self, id: span::Id) {
|
||||
self.subscriber.drop_span(id)
|
||||
|
@ -6,16 +6,17 @@ use {field, Metadata};
|
||||
///
|
||||
/// An `Event` can be compared to a log record in unstructured logging, but with
|
||||
/// two key differences:
|
||||
/// - `Event`s exist _within the context of a [`Span`]_. Unlike log lines, they
|
||||
/// - `Event`s exist _within the context of a [span]_. Unlike log lines, they
|
||||
/// may be located within the trace tree, allowing visibility into the
|
||||
/// _temporal_ context in which the event occurred, as well as the source
|
||||
/// code location.
|
||||
/// - Like spans, `Event`s have structured key-value data known as _fields_,
|
||||
/// - Like spans, `Event`s have structured key-value data known as _[fields]_,
|
||||
/// which may include textual message. In general, a majority of the data
|
||||
/// associated with an event should be in the event's fields rather than in
|
||||
/// the textual message, as the fields are more structed.
|
||||
///
|
||||
/// [`Span`]: ::span::Span
|
||||
/// [span]: ../span
|
||||
/// [fields]: ../field
|
||||
#[derive(Debug)]
|
||||
pub struct Event<'a> {
|
||||
fields: &'a field::ValueSet<'a>,
|
||||
@ -35,20 +36,20 @@ impl<'a> Event<'a> {
|
||||
|
||||
/// Visits all the fields on this `Event` with the specified [visitor].
|
||||
///
|
||||
/// [visitor]: ::field::Visit
|
||||
/// [visitor]: ../field/trait.Visit.html
|
||||
#[inline]
|
||||
pub fn record(&self, visitor: &mut field::Visit) {
|
||||
self.fields.record(visitor);
|
||||
}
|
||||
|
||||
/// Returns a reference to the set of values on this `Event`.
|
||||
/// Returns an iterator over the set of values on this `Event`.
|
||||
pub fn fields(&self) -> field::Iter {
|
||||
self.fields.field_set().iter()
|
||||
}
|
||||
|
||||
/// Returns [metadata] describing this `Event`.
|
||||
///
|
||||
/// [metadata]: ::metadata::Metadata
|
||||
/// [metadata]: ../metadata/struct.Metadata.html
|
||||
pub fn metadata(&self) -> &Metadata {
|
||||
self.metadata
|
||||
}
|
||||
|
@ -1,36 +1,42 @@
|
||||
//! `Span` and `Event` key-value data.
|
||||
//! Span and `Event` key-value data.
|
||||
//!
|
||||
//! Spans and events may be annotated with key-value data, referred to as known
|
||||
//! as _fields_. These fields consist of a mapping from a key (corresponding to
|
||||
//! a `&str` but represented internally as an array index) to a `Value`.
|
||||
//! a `&str` but represented internally as an array index) to a [`Value`].
|
||||
//!
|
||||
//! # `Value`s and `Subscriber`s
|
||||
//!
|
||||
//! `Subscriber`s consume `Value`s as fields attached to `Span`s or `Event`s.
|
||||
//! The set of field keys on a given `Span` or is defined on its `Metadata`.
|
||||
//! When a `Span` is created, it provides a `ValueSet` to the `Subscriber`'s
|
||||
//! `Subscriber`s consume `Value`s as fields attached to [span]s or [`Event`]s.
|
||||
//! The set of field keys on a given span or is defined on its [`Metadata`].
|
||||
//! When a span is created, it provides [`Attributes`] to the `Subscriber`'s
|
||||
//! [`new_span`] method, containing any fields whose values were provided when
|
||||
//! the span was created; and may call the `Subscriber`'s [`record`] method
|
||||
//! with additional `ValueSet`s if values are added for more of its fields.
|
||||
//! with additional [`Record`]s if values are added for more of its fields.
|
||||
//! Similarly, the [`Event`] type passed to the subscriber's [`event`] method
|
||||
//! will contain any fields attached to each event.
|
||||
//!
|
||||
//! `tokio_trace` represents values as either one of a set of Rust primitives
|
||||
//! (`i64`, `u64`, `bool`, and `&str`) or using a `fmt::Display` or `fmt::Debug`
|
||||
//! implementation. The `record_` trait functions on the `Subscriber` trait
|
||||
//! implementation. The [`record`] trait method on the `Subscriber` trait
|
||||
//! allow `Subscriber` implementations to provide type-specific behaviour for
|
||||
//! consuming values of each type.
|
||||
//!
|
||||
//! Instances of the `Visit` trait are provided by `Subscriber`s to record the
|
||||
//! values attached to `Span`s and `Event`. This trait represents the behavior
|
||||
//! Instances of the [`Visit`] trait are provided by `Subscriber`s to record the
|
||||
//! values attached to spans and `Event`. This trait represents the behavior
|
||||
//! used to record values of various types. For example, we might record
|
||||
//! integers by incrementing counters for their field names, rather than printing
|
||||
//! them.
|
||||
//!
|
||||
//! [`new_span`]: ::subscriber::Subscriber::new_span
|
||||
//! [`record`]: ::subscriber::Subscriber::record
|
||||
//! [`Event`]: ::event::Event
|
||||
//! [`event`]: ::subscriber::Subscriber::event
|
||||
//! [`Value`]: trait.Value.html
|
||||
//! [span]: ../span/
|
||||
//! [`Event`]: ../event/struct.Event.html
|
||||
//! [`Metadata`]: ../metadata/struct.Metadata.html
|
||||
//! [`Attributes`]: ../span/struct.Attributes.html
|
||||
//! [`Record`]: ../span/struct.Record.html
|
||||
//! [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
|
||||
//! [`record`]: ../subscriber/trait.Subscriber.html#method.record
|
||||
//! [`event`]: ../subscriber/trait.Subscriber.html#method.record
|
||||
//! [`Visit`]: trait.Visit.html
|
||||
use callsite;
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
@ -169,13 +175,13 @@ pub struct Iter {
|
||||
/// `examples/counters.rs`, which demonstrates a very simple metrics system
|
||||
/// implemented using `tokio-trace`.
|
||||
///
|
||||
/// [`Value`]: ::field::Value
|
||||
/// [recorded]: ::field::Value::record
|
||||
/// [`Subscriber`]: ::subscriber::Subscriber
|
||||
/// [records an `Event`]: ::subscriber::Subscriber::event
|
||||
/// [set of `Value`s added to a `Span`]: ::subscriber::Subscriber::record
|
||||
/// [`Event`]: ::event::Event
|
||||
/// [`ValueSet`]: ::field::ValueSet
|
||||
/// [`Value`]: trait.Value.html
|
||||
/// [recorded]: trait.Value.html#method.record
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [records an `Event`]: ../subscriber/trait.Subscriber.html#method.event
|
||||
/// [set of `Value`s added to a `Span`]: ../subscriber/trait.Subscriber.html#method.record
|
||||
/// [`Event`]: ../event/struct.Event.html
|
||||
/// [`ValueSet`]: struct.ValueSet.html
|
||||
pub trait Visit {
|
||||
/// Visit a signed 64-bit integer value.
|
||||
fn record_i64(&mut self, field: &Field, value: i64) {
|
||||
@ -207,7 +213,7 @@ pub trait Visit {
|
||||
/// the [visitor] passed to their `record` method in order to indicate how
|
||||
/// their data should be recorded.
|
||||
///
|
||||
/// [visitor]: ::field::Visit
|
||||
/// [visitor]: trait.Visit.html
|
||||
pub trait Value: ::sealed::Sealed {
|
||||
/// Visits this value with the given `Visitor`.
|
||||
fn record(&self, key: &Field, visitor: &mut Visit);
|
||||
@ -377,8 +383,11 @@ where
|
||||
// ===== impl Field =====
|
||||
|
||||
impl Field {
|
||||
/// Returns an [`Identifier`](::metadata::Identifier) that uniquely
|
||||
/// identifies the callsite that defines the field this key refers to.
|
||||
/// Returns an [`Identifier`] that uniquely identifies the [`Callsite`]
|
||||
/// which defines this field.
|
||||
///
|
||||
/// [`Identifier`]: ../callsite/struct.Identifier.html
|
||||
/// [`Callsite`]: ../callsite/trait.Callsite.html
|
||||
#[inline]
|
||||
pub fn callsite(&self) -> callsite::Identifier {
|
||||
self.fields.callsite()
|
||||
@ -435,12 +444,18 @@ impl Clone for Field {
|
||||
// ===== impl FieldSet =====
|
||||
|
||||
impl FieldSet {
|
||||
/// Returns an [`Identifier`] that uniquely identifies the [`Callsite`]
|
||||
/// which defines this set of fields..
|
||||
///
|
||||
/// [`Identifier`]: ../callsite/struct.Identifier.html
|
||||
/// [`Callsite`]: ../callsite/trait.Callsite.html
|
||||
pub(crate) fn callsite(&self) -> callsite::Identifier {
|
||||
callsite::Identifier(self.callsite.0)
|
||||
}
|
||||
|
||||
/// Returns the [`Field`](::field::Field) named `name`, or `None` if no such
|
||||
/// field exists.
|
||||
/// Returns the [`Field`] named `name`, or `None` if no such field exists.
|
||||
///
|
||||
/// [`Field`]: ../struct.Field.html
|
||||
pub fn field<Q: ?Sized>(&self, name: &Q) -> Option<Field>
|
||||
where
|
||||
Q: Borrow<str>,
|
||||
@ -537,8 +552,11 @@ impl Iterator for Iter {
|
||||
// ===== impl ValueSet =====
|
||||
|
||||
impl<'a> ValueSet<'a> {
|
||||
/// Returns an [`Identifier`](::metadata::Identifier) that uniquely
|
||||
/// identifies the callsite that defines the fields this `ValueSet` refers to.
|
||||
/// Returns an [`Identifier`] that uniquely identifies the [`Callsite`]
|
||||
/// defining the fields this `ValueSet` refers to.
|
||||
///
|
||||
/// [`Identifier`]: ../callsite/struct.Identifier.html
|
||||
/// [`Callsite`]: ../callsite/trait.Callsite.html
|
||||
#[inline]
|
||||
pub fn callsite(&self) -> callsite::Identifier {
|
||||
self.fields.callsite()
|
||||
@ -546,7 +564,7 @@ impl<'a> ValueSet<'a> {
|
||||
|
||||
/// Visits all the fields in this `ValueSet` with the provided [visitor].
|
||||
///
|
||||
/// [visitor]: ::field::Visit
|
||||
/// [visitor]: ../trait.Visit.html
|
||||
pub(crate) fn record(&self, visitor: &mut Visit) {
|
||||
let my_callsite = self.callsite();
|
||||
for (field, value) in self.values {
|
||||
|
@ -78,9 +78,9 @@ extern crate lazy_static;
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// [`Identifier`]: ::callsite::Identifier
|
||||
/// [`Callsite`]: ::callsite::Callsite
|
||||
/// [`Callsite::id`]: ::callsite::Callsite::id
|
||||
/// [`Identifier`]: callsite/struct.Identifier.html
|
||||
/// [`Callsite`]: callsite/trait.Callsite.html
|
||||
/// [`Callsite`]: callsite/trait.Callsite.html#method.id
|
||||
#[macro_export]
|
||||
macro_rules! identify_callsite {
|
||||
($callsite:expr) => {
|
||||
@ -121,8 +121,8 @@ macro_rules! identify_callsite {
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// [metadata]: ::metadata::Metadata
|
||||
/// [`Metadata::new`]: ::metadata::Metadata::new
|
||||
/// [metadata]: metadata/struct.Metadata.html
|
||||
/// [`Metadata::new`]: metadata/struct.Metadata.html#method.new
|
||||
#[macro_export]
|
||||
macro_rules! metadata {
|
||||
(
|
||||
|
@ -5,7 +5,7 @@ use super::{
|
||||
};
|
||||
use std::fmt;
|
||||
|
||||
/// Metadata describing a [`Span`].
|
||||
/// Metadata describing a [span] or [event].
|
||||
///
|
||||
/// This includes the source code location where the span occurred, the names of
|
||||
/// its fields, et cetera.
|
||||
@ -25,10 +25,10 @@ use std::fmt;
|
||||
/// originated. This can be used for determining if two Metadata correspond to
|
||||
/// the same callsite.
|
||||
///
|
||||
/// [`Span`]: ::span::Span
|
||||
/// [`Subscriber`]: ::Subscriber
|
||||
/// [`Metadata::id()`]: ::metadata::Metadata::id
|
||||
/// [callsite identifier]: ::callsite::Identifier
|
||||
/// [span]: ../span
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`Metadata::id()`]: struct.Metadata.html#method.id
|
||||
/// [callsite identifier]: ../callsite/struct.Identifier.html
|
||||
// TODO: When `const fn` is stable, make this type's fields private.
|
||||
pub struct Metadata<'a> {
|
||||
/// The name of the span described by this metadata.
|
||||
|
@ -4,10 +4,13 @@ use {field, Metadata};
|
||||
|
||||
/// Identifies a span within the context of a subscriber.
|
||||
///
|
||||
/// They are generated by [`Subscriber`](::Subscriber)s for each span as it is
|
||||
/// created, by the [`new_span`](::Subscriber::new_span) trait
|
||||
/// method. See the documentation for that method for more information on span
|
||||
/// They are generated by [`Subscriber`]s for each span as it is created, by
|
||||
/// the [`new_span`] trait method. See the documentation for that method for
|
||||
/// more information on span
|
||||
/// ID generation.
|
||||
///
|
||||
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
|
||||
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Id(u64);
|
||||
|
||||
@ -134,7 +137,7 @@ impl<'a> Attributes<'a> {
|
||||
/// Records all the fields in this set of `Attributes` with the provided
|
||||
/// [Visitor].
|
||||
///
|
||||
/// [visitor]: ::field::Visit
|
||||
/// [visitor]: ../field/trait.Visit.html
|
||||
pub fn record(&self, visitor: &mut field::Visit) {
|
||||
self.values.record(visitor)
|
||||
}
|
||||
@ -161,7 +164,7 @@ impl<'a> Record<'a> {
|
||||
|
||||
/// Records all the fields in this `Record` with the provided [Visitor].
|
||||
///
|
||||
/// [visitor]: ::field::Visit
|
||||
/// [visitor]: ../field/trait.Visit.html
|
||||
pub fn record(&self, visitor: &mut field::Visit) {
|
||||
self.values.record(visitor)
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ use {span, Event, Metadata};
|
||||
/// not be needed by the implementations of `enter` and `exit`, the subscriber
|
||||
/// may freely discard that data without allocating space to store it.
|
||||
///
|
||||
/// [ID]: ::span::Span
|
||||
/// [`new_span`]: ::Span::new_span
|
||||
/// [ID]: ../span/struct.Id.html
|
||||
/// [`new_span`]: trait.Subscriber.html#method.new_span
|
||||
pub trait Subscriber: 'static {
|
||||
// === Span registry methods ==============================================
|
||||
|
||||
@ -51,7 +51,7 @@ pub trait Subscriber: 'static {
|
||||
/// preallocate storage for that callsite, or perform any other actions it
|
||||
/// wishes to perform once for each callsite.
|
||||
///
|
||||
/// The subscriber should then return an [`Interest`](Interest), indicating
|
||||
/// The subscriber should then return an [`Interest`], indicating
|
||||
/// whether it is interested in being notified about that callsite in the
|
||||
/// future. This may be `Always` indicating that the subscriber always
|
||||
/// wishes to be notified about the callsite, and its filter need not be
|
||||
@ -88,8 +88,9 @@ pub trait Subscriber: 'static {
|
||||
/// callsite, it _may_ still see spans and events originating from that
|
||||
/// callsite, if another subscriber expressed interest in it.
|
||||
///
|
||||
/// [metadata]: ::Metadata
|
||||
/// [`enabled`]: ::Subscriber::enabled
|
||||
/// [metadata]: ../metadata/struct.Metadata.html
|
||||
/// [`Interest`]: struct.Interest.html
|
||||
/// [`enabled`]: #method.enabled
|
||||
fn register_callsite(&self, metadata: &Metadata) -> Interest {
|
||||
match self.enabled(metadata) {
|
||||
true => Interest::always(),
|
||||
@ -103,15 +104,15 @@ pub trait Subscriber: 'static {
|
||||
/// This is used by the dispatcher to avoid allocating for span construction
|
||||
/// if the span would be discarded anyway.
|
||||
///
|
||||
/// [metadata]: ::Metadata
|
||||
/// [metadata]: ../metadata/struct.Metadata.html
|
||||
fn enabled(&self, metadata: &Metadata) -> bool;
|
||||
|
||||
/// Visit the construction of a new span, returning a new [span ID] for the
|
||||
/// span being constructed.
|
||||
///
|
||||
/// The provided `ValueSet` contains any field values that were provided
|
||||
/// The provided [`Attributes`] contains any field values that were provided
|
||||
/// when the span was created. The subscriber may pass a [visitor] to the
|
||||
/// `ValueSet`'s [`record` method] to record these values.
|
||||
/// `Attributes`' [`record` method] to record these values.
|
||||
///
|
||||
/// IDs are used to uniquely identify spans and events within the context of a
|
||||
/// subscriber, so span equality will be based on the returned ID. Thus, if
|
||||
@ -123,8 +124,9 @@ pub trait Subscriber: 'static {
|
||||
/// the metadata.
|
||||
///
|
||||
/// [span ID]: ../span/struct.Id.html
|
||||
/// [visitor]: ::field::Visit
|
||||
/// [`record` method]: ::field::ValueSet::record
|
||||
/// [`Attributes`]: ../span/struct.Attributes.html
|
||||
/// [visitor]: ../field/trait.Visit.html
|
||||
/// [`record` method]: ../span/struct.Attributes.html#method.record
|
||||
fn new_span(&self, span: &span::Attributes) -> span::Id;
|
||||
|
||||
// === Notification methods ===============================================
|
||||
@ -134,8 +136,8 @@ pub trait Subscriber: 'static {
|
||||
/// The subscriber is expected to provide a [visitor] to the `Record`'s
|
||||
/// [`record` method] in order to record the added values.
|
||||
///
|
||||
/// [visitor]: ::field::Visit
|
||||
/// [`record` method]: ::span::Record::record
|
||||
/// [visitor]: ../field/trait.Visit.html
|
||||
/// [`record` method]: ../span/struct.Record.html#method.record
|
||||
fn record(&self, span: &span::Id, values: &span::Record);
|
||||
|
||||
/// Adds an indication that `span` follows from the span with the id
|
||||
@ -164,9 +166,9 @@ pub trait Subscriber: 'static {
|
||||
/// event. The subscriber may pass a [visitor] to the `Event`'s
|
||||
/// [`record` method] to record these values.
|
||||
///
|
||||
/// [`Event`]: ::event::Event
|
||||
/// [visitor]: ::field::Visit
|
||||
/// [`record` method]: ::event::Event::record
|
||||
/// [`Event`]: ../event/struct.Event.html
|
||||
/// [visitor]: ../field/trait.Visit.html
|
||||
/// [`record` method]: ../event/struct.Event.html#method.record
|
||||
fn event(&self, event: &Event);
|
||||
|
||||
/// Visits that a spanhas been entered.
|
||||
@ -210,7 +212,7 @@ pub trait Subscriber: 'static {
|
||||
/// what that means for the specified pointer.
|
||||
///
|
||||
/// [span ID]: ../span/struct.Id.html
|
||||
/// [`drop_span`]: ::subscriber::Subscriber::drop_span
|
||||
/// [`drop_span`]: trait.Subscriber.html#method.drop_span
|
||||
fn clone_span(&self, id: &span::Id) -> span::Id {
|
||||
id.clone()
|
||||
}
|
||||
@ -236,7 +238,7 @@ pub trait Subscriber: 'static {
|
||||
/// was dropped due to a thread unwinding.
|
||||
///
|
||||
/// [span ID]: ../span/struct.Id.html
|
||||
/// [`drop_span`]: ::subscriber::Subscriber::drop_span
|
||||
/// [`clone_span`]: trait.Subscriber.html#method.clone_span
|
||||
fn drop_span(&self, id: span::Id) {
|
||||
let _ = id;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user