@@ -686,7 +686,31 @@ pub(crate) mod tests;
686
686
/// be composed together with other subscribers to build a [collector]. See the
687
687
/// [module-level documentation](crate::subscribe) for details.
688
688
///
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
+ ///
689
710
/// [collector]: tracing_core::Collect
711
+ /// [`enabled`]: Self::enabled
712
+ /// [`event_enabled`]: Self::event_enabled
713
+ /// [`register_callsite`]: Self::register_callsite
690
714
#[ cfg_attr( docsrs, doc( notable_trait) ) ]
691
715
pub trait Subscribe < C >
692
716
where
@@ -827,7 +851,7 @@ where
827
851
// seems like a good future-proofing measure as it may grow other methods later...
828
852
fn on_follows_from ( & self , _span : & span:: Id , _follows : & span:: Id , _ctx : Context < ' _ , C > ) { }
829
853
830
- /// Called before `on_event`, to determine if `on_event` should be called.
854
+ /// Called before [ `on_event`] , to determine if `on_event` should be called.
831
855
///
832
856
/// <div class="example-wrap" style="display:inline-block">
833
857
/// <pre class="ignore" style="white-space:normal;font:inherit;">
@@ -844,6 +868,7 @@ where
844
868
/// See [the trait-level documentation] for more information on filtering
845
869
/// with `Subscriber`s.
846
870
///
871
+ /// [`on_event`]: Self::on_event
847
872
/// [`Interest`]: tracing_core::Interest
848
873
/// [the trait-level documentation]: #filtering-with-subscribers
849
874
#[ inline] // collapse this to a constant please mrs optimizer
0 commit comments