Skip to content

Commit 5c7abbb

Browse files
hawkwkaffarell
authored andcommitted
core: document the callsite module (tokio-rs#2088)
Currently, there isn't a lot of documentation explaining what callsites and registration are for, and how they work. There's some documentation explaining this stuff, but it's all on the `register_callsite` *method*, rather than in the `callsite` module itself. We should fix that. This branch adds new documentation to `tracing-core`'s `callsite` module. Hopefully this should shine some light on how this part of tracing works. Thanks to @JamesHallowell for fixing some typos! Signed-off-by: Eliza Weisman <[email protected]>
1 parent c5fa327 commit 5c7abbb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tracing-core/src/subscriber.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ use crate::stdlib::{
5656
/// Additionally, subscribers which wish to perform a behaviour once for each
5757
/// callsite, such as allocating storage for data related to that callsite,
5858
/// can perform it in `register_callsite`.
59+
///
60+
/// See also the [documentation on the callsite registry][cs-reg] for details
61+
/// on [`register_callsite`].
62+
///
5963
/// - [`clone_span`] is called every time a span ID is cloned, and [`try_close`]
6064
/// is called when a span ID is dropped. By default, these functions do
6165
/// nothing. However, they can be used to implement reference counting for
@@ -70,10 +74,11 @@ use crate::stdlib::{
7074
/// [`enabled`]: Subscriber::enabled
7175
/// [`clone_span`]: Subscriber::clone_span
7276
/// [`try_close`]: Subscriber::try_close
77+
/// [cs-reg]: crate::callsite#registering-callsites
7378
pub trait Subscriber: 'static {
7479
// === Span registry methods ==============================================
7580

76-
/// Registers a new callsite with this subscriber, returning whether or not
81+
/// Registers a new [callsite] with this subscriber, returning whether or not
7782
/// the subscriber is interested in being notified about the callsite.
7883
///
7984
/// By default, this function assumes that the subscriber's [filter]
@@ -127,6 +132,9 @@ pub trait Subscriber: 'static {
127132
/// return `Interest::Never`, as a new subscriber may be added that _is_
128133
/// interested.
129134
///
135+
/// See the [documentation on the callsite registry][cs-reg] for more
136+
/// details on how and when the `register_callsite` method is called.
137+
///
130138
/// # Notes
131139
/// This function may be called again when a new subscriber is created or
132140
/// when the registry is invalidated.
@@ -135,10 +143,12 @@ pub trait Subscriber: 'static {
135143
/// _may_ still see spans and events originating from that callsite, if
136144
/// another subscriber expressed interest in it.
137145
///
138-
/// [filter]: Subscriber::enabled()
146+
/// [callsite]: crate::callsite
147+
/// [filter]: Self::enabled
139148
/// [metadata]: super::metadata::Metadata
140149
/// [`enabled`]: Subscriber::enabled()
141150
/// [`rebuild_interest_cache`]: super::callsite::rebuild_interest_cache
151+
/// [cs-reg]: crate::callsite#registering-callsites
142152
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest {
143153
if self.enabled(metadata) {
144154
Interest::always()

0 commit comments

Comments
 (0)