|
417 | 417 | //! [`Interest::never()`] from its [`register_callsite`] method, filter
|
418 | 418 | //! evaluation will short-circuit and the span or event will be disabled.
|
419 | 419 | //!
|
| 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 | +//! |
420 | 442 | //! ## Per-Subscriber Filtering
|
421 | 443 | //!
|
422 | 444 | //! **Note**: per-subscriber filtering APIs currently require the [`"registry"` crate
|
|
639 | 661 | //! [the current span]: Context::current_span
|
640 | 662 | //! [`register_callsite`]: Subscribe::register_callsite
|
641 | 663 | //! [`enabled`]: Subscribe::enabled
|
| 664 | +//! [`event_enabled`]: Subscribe::event_enabled |
642 | 665 | //! [`on_enter`]: Subscribe::on_enter
|
643 | 666 | //! [`Subscribe::register_callsite`]: Subscribe::register_callsite
|
644 | 667 | //! [`Subscribe::enabled`]: Subscribe::enabled
|
@@ -686,31 +709,7 @@ pub(crate) mod tests;
|
686 | 709 | /// be composed together with other subscribers to build a [collector]. See the
|
687 | 710 | /// [module-level documentation](crate::subscribe) for details.
|
688 | 711 | ///
|
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 |
| -/// |
710 | 712 | /// [collector]: tracing_core::Collect
|
711 |
| -/// [`enabled`]: Self::enabled |
712 |
| -/// [`event_enabled`]: Self::event_enabled |
713 |
| -/// [`register_callsite`]: Self::register_callsite |
714 | 713 | #[cfg_attr(docsrs, doc(notable_trait))]
|
715 | 714 | pub trait Subscribe<C>
|
716 | 715 | where
|
@@ -858,10 +857,10 @@ where
|
858 | 857 | ///
|
859 | 858 | /// **Note**: This method determines whether an event is globally enabled,
|
860 | 859 | /// *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]. |
865 | 864 | ///
|
866 | 865 | /// </pre></div>
|
867 | 866 | ///
|
|
0 commit comments