Skip to content

Commit f5f1758

Browse files
CAD97hawkw
andcommitted
Apply code review documentation improvements
Co-authored-by: Eliza Weisman <[email protected]>
1 parent 53ed1dc commit f5f1758

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

tracing-core/src/collect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ use core::ptr::NonNull;
5757
/// See also the [documentation on the callsite registry][cs-reg] for details
5858
/// on [`register_callsite`].
5959
///
60-
/// - [`event_enabled`] is called once before every [`event`] is recorded. This
61-
/// can be used to implement filtering on events once their field values are
62-
/// known but before any processing is done in `event`.
60+
/// - [`event_enabled`] is called once before every call to the [`event`]
61+
/// method. This can be used to implement filtering on events once their field
62+
/// values are known, but before any processing is done in the `event` method.
6363
/// - [`clone_span`] is called every time a span ID is cloned, and [`try_close`]
6464
/// is called when a span ID is dropped. By default, these functions do
6565
/// nothing. However, they can be used to implement reference counting for

tracing-subscriber/src/subscribe/mod.rs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,28 @@
417417
//! [`Interest::never()`] from its [`register_callsite`] method, filter
418418
//! evaluation will short-circuit and the span or event will be disabled.
419419
//!
420+
//! ### Enabling interest
421+
//!
422+
//! Whenever an tracing event (or span) is emitted, it goes through a number of
423+
//! steps to determine how and how much it should be processed. The earlier an
424+
//! event is disabled, the less work has to be done to process the event, so
425+
//! subscribers that implement filtering should attempt to disable unwanted
426+
//! events as early as possible. In order, each event checks:
427+
//!
428+
//! - [`register_callsite`], once per callsite (roughly: once per time that
429+
//! `event!` or `span!` is written in the source code; this is cached at the
430+
//! callsite). See [`Collect::register_callsite`] and
431+
//! [`tracing_core::callsite`] for a summary of how this behaves.
432+
//! - [`enabled`], once per emitted event (roughly: once per time that `event!`
433+
//! or `span!` is *executed*), and only if `register_callsite` regesters an
434+
//! [`Interest::sometimes`]. This is the main customization point to globally
435+
//! filter events based on their [`Metadata`]. If an event can be disabled
436+
//! based only on [`Metadata`], it should be, as this allows the construction
437+
//! of the actual `Event`/`Span` to be skipped.
438+
//! - For events only (and not spans), [`event_enabled`] is called just before
439+
//! processing the event. This gives subscribers one last chance to say that
440+
//! an event should be filtered out, now that the event's fields are known.
441+
//!
420442
//! ## Per-Subscriber Filtering
421443
//!
422444
//! **Note**: per-subscriber filtering APIs currently require the [`"registry"` crate
@@ -639,6 +661,7 @@
639661
//! [the current span]: Context::current_span
640662
//! [`register_callsite`]: Subscribe::register_callsite
641663
//! [`enabled`]: Subscribe::enabled
664+
//! [`event_enabled`]: Subscribe::event_enabled
642665
//! [`on_enter`]: Subscribe::on_enter
643666
//! [`Subscribe::register_callsite`]: Subscribe::register_callsite
644667
//! [`Subscribe::enabled`]: Subscribe::enabled
@@ -686,31 +709,7 @@ pub(crate) mod tests;
686709
/// be composed together with other subscribers to build a [collector]. See the
687710
/// [module-level documentation](crate::subscribe) for details.
688711
///
689-
/// # Enabling interest
690-
///
691-
/// Whenever an tracing event (or span) is emitted, it goes through a number of
692-
/// steps to determine how and how much it should be processed. The earlier an
693-
/// event is disabled, the less work has to be done to process the event, so
694-
/// subscribers should attempt to provide accurate information as early as
695-
/// possible. Note that this determines **global** interest for the entire stack
696-
/// of subscribers; a subscriber that wants to ignore certain events/spans
697-
/// should just ignore them in the notifications. In order, each event checks:
698-
///
699-
/// - [`register_callsite`], once per callsite (roughly: once per time that
700-
/// `event!` or `span!` is written in the source code; this is cached at the
701-
/// callsite). See [`Collect::register_callsite`] for how this behaves.
702-
/// - [`enabled`], once per emitted event (or span). This is the main point to
703-
/// (globally) filter events based on their [`Metadata`]. If an event can be
704-
/// disabled by just its structure, it should be, as this allows construction
705-
/// of the actual `Event`/`Span` to be skipped.
706-
/// - For events only (and not spans), [`event_enabled`] is called just before
707-
/// processing the event. This gives subscribers one last chance to say that
708-
/// an event should be filtered out, now that the event's fields are known.
709-
///
710712
/// [collector]: tracing_core::Collect
711-
/// [`enabled`]: Self::enabled
712-
/// [`event_enabled`]: Self::event_enabled
713-
/// [`register_callsite`]: Self::register_callsite
714713
#[cfg_attr(docsrs, doc(notable_trait))]
715714
pub trait Subscribe<C>
716715
where
@@ -858,10 +857,10 @@ where
858857
///
859858
/// **Note**: This method determines whether an event is globally enabled,
860859
/// *not* whether the individual subscriber will be notified about the
861-
/// event. This is intended to be used by layers that implement filtering
862-
/// for the entire stack. Layers which do not wish to be notified about
863-
/// certain events but do not wish to globally disable them should ignore
864-
/// those events in their [on_event][Self::on_event].
860+
/// event. This is intended to be used by subscibers that implement
861+
/// filtering for the entire stack. Subscribers which do not wish to be
862+
/// notified about certain events but do not wish to globally disable them
863+
/// should ignore those events in their [on_event][Self::on_event].
865864
///
866865
/// </pre></div>
867866
///

0 commit comments

Comments
 (0)