|
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
|
@@ -858,10 +881,10 @@ where
|
858 | 881 | ///
|
859 | 882 | /// **Note**: This method determines whether an event is globally enabled,
|
860 | 883 | /// *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]. |
| 884 | + /// event. This is intended to be used by subscibers that implement |
| 885 | + /// filtering for the entire stack. Subscribers which do not wish to be |
| 886 | + /// notified about certain events but do not wish to globally disable them |
| 887 | + /// should ignore those events in their [on_event][Self::on_event]. |
865 | 888 | ///
|
866 | 889 | /// </pre></div>
|
867 | 890 | ///
|
|
0 commit comments