1 //! Subscribers collect and record trace data.
2 use crate::{span, Event, LevelFilter, Metadata}
;
10 /// Trait representing the functions required to collect trace data.
12 /// Crates that provide implementations of methods for collecting or recording
13 /// trace data should implement the `Subscriber` interface. This trait is
14 /// intended to represent fundamental primitives for collecting trace events and
15 /// spans — other libraries may offer utility functions and types to make
16 /// subscriber implementations more modular or improve the ergonomics of writing
19 /// A subscriber is responsible for the following:
20 /// - Registering new spans as they are created, and providing them with span
21 /// IDs. Implicitly, this means the subscriber may determine the strategy for
22 /// determining span equality.
23 /// - Recording the attachment of field values and follows-from annotations to
25 /// - Filtering spans and events, and determining when those filters must be
27 /// - Observing spans as they are entered, exited, and closed, and events as
30 /// When a span is entered or exited, the subscriber is provided only with the
31 /// [ID] with which it tagged that span when it was created. This means
32 /// that it is up to the subscriber to determine whether and how span _data_ —
33 /// the fields and metadata describing the span — should be stored. The
34 /// [`new_span`] function is called when a new span is created, and at that
35 /// point, the subscriber _may_ choose to store the associated data if it will
36 /// be referenced again. However, if the data has already been recorded and will
37 /// not be needed by the implementations of `enter` and `exit`, the subscriber
38 /// may freely discard that data without allocating space to store it.
40 /// ## Overriding default impls
42 /// Some trait methods on `Subscriber` have default implementations, either in
43 /// order to reduce the surface area of implementing `Subscriber`, or for
44 /// backward-compatibility reasons. However, many subscribers will likely want
45 /// to override these default implementations.
47 /// The following methods are likely of interest:
49 /// - [`register_callsite`] is called once for each callsite from which a span
50 /// event may originate, and returns an [`Interest`] value describing whether or
51 /// not the subscriber wishes to see events or spans from that callsite. By
52 /// default, it calls [`enabled`], and returns `Interest::always()` if
53 /// `enabled` returns true, or `Interest::never()` if enabled returns false.
54 /// However, if the subscriber's interest can change dynamically at runtime,
55 /// it may want to override this function to return `Interest::sometimes()`.
56 /// Additionally, subscribers which wish to perform a behaviour once for each
57 /// callsite, such as allocating storage for data related to that callsite,
58 /// can perform it in `register_callsite`.
60 /// See also the [documentation on the callsite registry][cs-reg] for details
61 /// on [`register_callsite`].
63 /// - [`clone_span`] is called every time a span ID is cloned, and [`try_close`]
64 /// is called when a span ID is dropped. By default, these functions do
65 /// nothing. However, they can be used to implement reference counting for
66 /// spans, allowing subscribers to free storage for span data and to determine
67 /// when a span has _closed_ permanently (rather than being exited).
68 /// Subscribers which store per-span data or which need to track span closures
69 /// should override these functions together.
71 /// [ID]: super::span::Id
72 /// [`new_span`]: Subscriber::new_span
73 /// [`register_callsite`]: Subscriber::register_callsite
74 /// [`enabled`]: Subscriber::enabled
75 /// [`clone_span`]: Subscriber::clone_span
76 /// [`try_close`]: Subscriber::try_close
77 /// [cs-reg]: crate::callsite#registering-callsites
78 pub trait Subscriber
: '
static {
79 // === Span registry methods ==============================================
81 /// Registers a new [callsite] with this subscriber, returning whether or not
82 /// the subscriber is interested in being notified about the callsite.
84 /// By default, this function assumes that the subscriber's [filter]
85 /// represents an unchanging view of its interest in the callsite. However,
86 /// if this is not the case, subscribers may override this function to
87 /// indicate different interests, or to implement behaviour that should run
88 /// once for every callsite.
90 /// This function is guaranteed to be called at least once per callsite on
91 /// every active subscriber. The subscriber may store the keys to fields it
92 /// cares about in order to reduce the cost of accessing fields by name,
93 /// preallocate storage for that callsite, or perform any other actions it
94 /// wishes to perform once for each callsite.
96 /// The subscriber should then return an [`Interest`], indicating
97 /// whether it is interested in being notified about that callsite in the
98 /// future. This may be `Always` indicating that the subscriber always
99 /// wishes to be notified about the callsite, and its filter need not be
100 /// re-evaluated; `Sometimes`, indicating that the subscriber may sometimes
101 /// care about the callsite but not always (such as when sampling), or
102 /// `Never`, indicating that the subscriber never wishes to be notified about
103 /// that callsite. If all active subscribers return `Never`, a callsite will
104 /// never be enabled unless a new subscriber expresses interest in it.
106 /// `Subscriber`s which require their filters to be run every time an event
107 /// occurs or a span is entered/exited should return `Interest::sometimes`.
108 /// If a subscriber returns `Interest::sometimes`, then its [`enabled`] method
109 /// will be called every time an event or span is created from that callsite.
111 /// For example, suppose a sampling subscriber is implemented by
112 /// incrementing a counter every time `enabled` is called and only returning
113 /// `true` when the counter is divisible by a specified sampling rate. If
114 /// that subscriber returns `Interest::always` from `register_callsite`, then
115 /// the filter will not be re-evaluated once it has been applied to a given
116 /// set of metadata. Thus, the counter will not be incremented, and the span
117 /// or event that corresponds to the metadata will never be `enabled`.
119 /// `Subscriber`s that need to change their filters occasionally should call
120 /// [`rebuild_interest_cache`] to re-evaluate `register_callsite` for all
123 /// Similarly, if a `Subscriber` has a filtering strategy that can be
124 /// changed dynamically at runtime, it would need to re-evaluate that filter
125 /// if the cached results have changed.
127 /// A subscriber which manages fanout to multiple other subscribers
128 /// should proxy this decision to all of its child subscribers,
129 /// returning `Interest::never` only if _all_ such children return
130 /// `Interest::never`. If the set of subscribers to which spans are
131 /// broadcast may change dynamically, the subscriber should also never
132 /// return `Interest::Never`, as a new subscriber may be added that _is_
135 /// See the [documentation on the callsite registry][cs-reg] for more
136 /// details on how and when the `register_callsite` method is called.
139 /// This function may be called again when a new subscriber is created or
140 /// when the registry is invalidated.
142 /// If a subscriber returns `Interest::never` for a particular callsite, it
143 /// _may_ still see spans and events originating from that callsite, if
144 /// another subscriber expressed interest in it.
146 /// [callsite]: crate::callsite
147 /// [filter]: Self::enabled
148 /// [metadata]: super::metadata::Metadata
149 /// [`enabled`]: Subscriber::enabled()
150 /// [`rebuild_interest_cache`]: super::callsite::rebuild_interest_cache
151 /// [cs-reg]: crate::callsite#registering-callsites
152 fn register_callsite(&self, metadata
: &'
static Metadata
<'
static>) -> Interest
{
153 if self.enabled(metadata
) {
160 /// Returns true if a span or event with the specified [metadata] would be
163 /// By default, it is assumed that this filter needs only be evaluated once
164 /// for each callsite, so it is called by [`register_callsite`] when each
165 /// callsite is registered. The result is used to determine if the subscriber
166 /// is always [interested] or never interested in that callsite. This is intended
167 /// primarily as an optimization, so that expensive filters (such as those
168 /// involving string search, et cetera) need not be re-evaluated.
170 /// However, if the subscriber's interest in a particular span or event may
171 /// change, or depends on contexts only determined dynamically at runtime,
172 /// then the `register_callsite` method should be overridden to return
173 /// [`Interest::sometimes`]. In that case, this function will be called every
174 /// time that span or event occurs.
176 /// [metadata]: super::metadata::Metadata
177 /// [interested]: Interest
178 /// [`Interest::sometimes`]: Interest::sometimes
179 /// [`register_callsite`]: Subscriber::register_callsite()
180 fn enabled(&self, metadata
: &Metadata
<'_
>) -> bool
;
182 /// Returns the highest [verbosity level][level] that this `Subscriber` will
183 /// enable, or `None`, if the subscriber does not implement level-based
184 /// filtering or chooses not to implement this method.
186 /// If this method returns a [`Level`][level], it will be used as a hint to
187 /// determine the most verbose level that will be enabled. This will allow
188 /// spans and events which are more verbose than that level to be skipped
189 /// more efficiently. Subscribers which perform filtering are strongly
190 /// encouraged to provide an implementation of this method.
192 /// If the maximum level the subscriber will enable can change over the
193 /// course of its lifetime, it is free to return a different value from
194 /// multiple invocations of this method. However, note that changes in the
195 /// maximum level will **only** be reflected after the callsite [`Interest`]
196 /// cache is rebuilt, by calling the [`callsite::rebuild_interest_cache`][rebuild]
197 /// function. Therefore, if the subscriber will change the value returned by
198 /// this method, it is responsible for ensuring that
199 /// [`rebuild_interest_cache`][rebuild] is called after the value of the max
202 /// [level]: super::Level
203 /// [rebuild]: super::callsite::rebuild_interest_cache
204 fn max_level_hint(&self) -> Option
<LevelFilter
> {
208 /// Visit the construction of a new span, returning a new [span ID] for the
209 /// span being constructed.
211 /// The provided [`Attributes`] contains any field values that were provided
212 /// when the span was created. The subscriber may pass a [visitor] to the
213 /// `Attributes`' [`record` method] to record these values.
215 /// IDs are used to uniquely identify spans and events within the context of a
216 /// subscriber, so span equality will be based on the returned ID. Thus, if
217 /// the subscriber wishes for all spans with the same metadata to be
218 /// considered equal, it should return the same ID every time it is given a
219 /// particular set of metadata. Similarly, if it wishes for two separate
220 /// instances of a span with the same metadata to *not* be equal, it should
221 /// return a distinct ID every time this function is called, regardless of
224 /// Note that the subscriber is free to assign span IDs based on whatever
225 /// scheme it sees fit. Any guarantees about uniqueness, ordering, or ID
226 /// reuse are left up to the subscriber implementation to determine.
228 /// [span ID]: super::span::Id
229 /// [`Attributes`]: super::span::Attributes
230 /// [visitor]: super::field::Visit
231 /// [`record` method]: super::span::Attributes::record
232 fn new_span(&self, span
: &span
::Attributes
<'_
>) -> span
::Id
;
234 // === Notification methods ===============================================
236 /// Record a set of values on a span.
238 /// This method will be invoked when value is recorded on a span.
239 /// Recording multiple values for the same field is possible,
240 /// but the actual behaviour is defined by the subscriber implementation.
242 /// Keep in mind that a span might not provide a value
243 /// for each field it declares.
245 /// The subscriber is expected to provide a [visitor] to the `Record`'s
246 /// [`record` method] in order to record the added values.
249 /// "foo = 3" will be recorded when [`record`] is called on the
250 /// `Attributes` passed to `new_span`.
251 /// Since values are not provided for the `bar` and `baz` fields,
252 /// the span's `Metadata` will indicate that it _has_ those fields,
253 /// but values for them won't be recorded at this time.
256 /// # use tracing::span;
258 /// let mut span = span!("my_span", foo = 3, bar, baz);
260 /// // `Subscriber::record` will be called with a `Record`
261 /// // containing "bar = false"
262 /// span.record("bar", &false);
264 /// // `Subscriber::record` will be called with a `Record`
265 /// // containing "baz = "a string""
266 /// span.record("baz", &"a string");
269 /// [visitor]: super::field::Visit
270 /// [`record`]: super::span::Attributes::record
271 /// [`record` method]: super::span::Record::record
272 fn record(&self, span
: &span
::Id
, values
: &span
::Record
<'_
>);
274 /// Adds an indication that `span` follows from the span with the id
277 /// This relationship differs somewhat from the parent-child relationship: a
278 /// span may have any number of prior spans, rather than a single one; and
279 /// spans are not considered to be executing _inside_ of the spans they
280 /// follow from. This means that a span may close even if subsequent spans
281 /// that follow from it are still open, and time spent inside of a
282 /// subsequent span should not be included in the time its precedents were
283 /// executing. This is used to model causal relationships such as when a
284 /// single future spawns several related background tasks, et cetera.
286 /// If the subscriber has spans corresponding to the given IDs, it should
287 /// record this relationship in whatever way it deems necessary. Otherwise,
288 /// if one or both of the given span IDs do not correspond to spans that the
289 /// subscriber knows about, or if a cyclical relationship would be created
290 /// (i.e., some span _a_ which proceeds some other span _b_ may not also
291 /// follow from _b_), it may silently do nothing.
292 fn record_follows_from(&self, span
: &span
::Id
, follows
: &span
::Id
);
294 /// Records that an [`Event`] has occurred.
296 /// This method will be invoked when an Event is constructed by
297 /// the `Event`'s [`dispatch` method]. For example, this happens internally
298 /// when an event macro from `tracing` is called.
300 /// The key difference between this method and `record` is that `record` is
301 /// called when a value is recorded for a field defined by a span,
302 /// while `event` is called when a new event occurs.
304 /// The provided `Event` struct contains any field values attached to the
305 /// event. The subscriber may pass a [visitor] to the `Event`'s
306 /// [`record` method] to record these values.
308 /// [`Event`]: super::event::Event
309 /// [visitor]: super::field::Visit
310 /// [`record` method]: super::event::Event::record
311 /// [`dispatch` method]: super::event::Event::dispatch
312 fn event(&self, event
: &Event
<'_
>);
314 /// Records that a span has been entered.
316 /// When entering a span, this method is called to notify the subscriber
317 /// that the span has been entered. The subscriber is provided with the
318 /// [span ID] of the entered span, and should update any internal state
319 /// tracking the current span accordingly.
321 /// [span ID]: super::span::Id
322 fn enter(&self, span
: &span
::Id
);
324 /// Records that a span has been exited.
326 /// When exiting a span, this method is called to notify the subscriber
327 /// that the span has been exited. The subscriber is provided with the
328 /// [span ID] of the exited span, and should update any internal state
329 /// tracking the current span accordingly.
331 /// Exiting a span does not imply that the span will not be re-entered.
333 /// [span ID]: super::span::Id
334 fn exit(&self, span
: &span
::Id
);
336 /// Notifies the subscriber that a [span ID] has been cloned.
338 /// This function is guaranteed to only be called with span IDs that were
339 /// returned by this subscriber's `new_span` function.
341 /// Note that the default implementation of this function this is just the
342 /// identity function, passing through the identifier. However, it can be
343 /// used in conjunction with [`try_close`] to track the number of handles
344 /// capable of `enter`ing a span. When all the handles have been dropped
345 /// (i.e., `try_close` has been called one more time than `clone_span` for a
346 /// given ID), the subscriber may assume that the span will not be entered
347 /// again. It is then free to deallocate storage for data associated with
348 /// that span, write data from that span to IO, and so on.
350 /// For more unsafe situations, however, if `id` is itself a pointer of some
351 /// kind this can be used as a hook to "clone" the pointer, depending on
352 /// what that means for the specified pointer.
354 /// [span ID]: super::span::Id
355 /// [`try_close`]: Subscriber::try_close
356 fn clone_span(&self, id
: &span
::Id
) -> span
::Id
{
360 /// **This method is deprecated.**
362 /// Using `drop_span` may result in subscribers composed using
363 /// `tracing-subscriber` crate's `Layer` trait from observing close events.
364 /// Use [`try_close`] instead.
366 /// The default implementation of this function does nothing.
368 /// [`try_close`]: Subscriber::try_close
369 #[deprecated(since = "0.1.2", note = "use `Subscriber::try_close` instead")]
370 fn drop_span(&self, _id
: span
::Id
) {}
372 /// Notifies the subscriber that a [span ID] has been dropped, and returns
373 /// `true` if there are now 0 IDs that refer to that span.
375 /// Higher-level libraries providing functionality for composing multiple
376 /// subscriber implementations may use this return value to notify any
377 /// "layered" subscribers that this subscriber considers the span closed.
379 /// The default implementation of this method calls the subscriber's
380 /// [`drop_span`] method and returns `false`. This means that, unless the
381 /// subscriber overrides the default implementation, close notifications
382 /// will never be sent to any layered subscribers. In general, if the
383 /// subscriber tracks reference counts, this method should be implemented,
384 /// rather than `drop_span`.
386 /// This function is guaranteed to only be called with span IDs that were
387 /// returned by this subscriber's `new_span` function.
389 /// It's guaranteed that if this function has been called once more than the
390 /// number of times `clone_span` was called with the same `id`, then no more
391 /// handles that can enter the span with that `id` exist. This means that it
392 /// can be used in conjunction with [`clone_span`] to track the number of
393 /// handles capable of `enter`ing a span. When all the handles have been
394 /// dropped (i.e., `try_close` has been called one more time than
395 /// `clone_span` for a given ID), the subscriber may assume that the span
396 /// will not be entered again, and should return `true`. It is then free to
397 /// deallocate storage for data associated with that span, write data from
398 /// that span to IO, and so on.
400 /// **Note**: since this function is called when spans are dropped,
401 /// implementations should ensure that they are unwind-safe. Panicking from
402 /// inside of a `try_close` function may cause a double panic, if the span
403 /// was dropped due to a thread unwinding.
405 /// [span ID]: super::span::Id
406 /// [`clone_span`]: Subscriber::clone_span
407 /// [`drop_span`]: Subscriber::drop_span
408 fn try_close(&self, id
: span
::Id
) -> bool
{
414 /// Returns a type representing this subscriber's view of the current span.
416 /// If subscribers track a current span, they should override this function
417 /// to return [`Current::new`] if the thread from which this method is
418 /// called is inside a span, or [`Current::none`] if the thread is not
421 /// By default, this returns a value indicating that the subscriber
422 /// does **not** track what span is current. If the subscriber does not
423 /// implement a current span, it should not override this method.
425 /// [`Current::new`]: super::span::Current#tymethod.new
426 /// [`Current::none`]: super::span::Current#tymethod.none
427 fn current_span(&self) -> span
::Current
{
428 span
::Current
::unknown()
431 // === Downcasting methods ================================================
433 /// If `self` is the same type as the provided `TypeId`, returns an untyped
434 /// `*const` pointer to that type. Otherwise, returns `None`.
436 /// If you wish to downcast a `Subscriber`, it is strongly advised to use
437 /// the safe API provided by [`downcast_ref`] instead.
439 /// This API is required for `downcast_raw` to be a trait method; a method
440 /// signature like [`downcast_ref`] (with a generic type parameter) is not
441 /// object-safe, and thus cannot be a trait method for `Subscriber`. This
442 /// means that if we only exposed `downcast_ref`, `Subscriber`
443 /// implementations could not override the downcasting behavior
445 /// This method may be overridden by "fan out" or "chained" subscriber
446 /// implementations which consist of multiple composed types. Such
447 /// subscribers might allow `downcast_raw` by returning references to those
448 /// component if they contain components with the given `TypeId`.
452 /// The [`downcast_ref`] method expects that the pointer returned by
453 /// `downcast_raw` is non-null and points to a valid instance of the type
454 /// with the provided `TypeId`. Failure to ensure this will result in
455 /// undefined behaviour, so implementing `downcast_raw` is unsafe.
457 /// [`downcast_ref`]: #method.downcast_ref
458 unsafe fn downcast_raw(&self, id
: TypeId
) -> Option
<*const ()> {
459 if id
== TypeId
::of
::<Self>() {
460 Some(self as *const Self as *const ())
467 impl dyn Subscriber
{
468 /// Returns `true` if this `Subscriber` is the same type as `T`.
469 pub fn is
<T
: Any
>(&self) -> bool
{
470 self.downcast_ref
::<T
>().is_some()
473 /// Returns some reference to this `Subscriber` value if it is of type `T`,
474 /// or `None` if it isn't.
475 pub fn downcast_ref
<T
: Any
>(&self) -> Option
<&T
> {
477 let raw
= self.downcast_raw(TypeId
::of
::<T
>())?
;
481 Some(&*(raw
as *const _
))
487 /// Indicates a [`Subscriber`]'s interest in a particular callsite.
489 /// `Subscriber`s return an `Interest` from their [`register_callsite`] methods
490 /// in order to determine whether that span should be enabled or disabled.
492 /// [`Subscriber`]: super::Subscriber
493 /// [`register_callsite`]: super::Subscriber::register_callsite
494 #[derive(Clone, Debug)]
495 pub struct Interest(InterestKind
);
497 #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
505 /// Returns an `Interest` indicating that the subscriber is never interested
506 /// in being notified about a callsite.
508 /// If all active subscribers are `never()` interested in a callsite, it will
509 /// be completely disabled unless a new subscriber becomes active.
511 pub fn never() -> Self {
512 Interest(InterestKind
::Never
)
515 /// Returns an `Interest` indicating the subscriber is sometimes interested
516 /// in being notified about a callsite.
518 /// If all active subscribers are `sometimes` or `never` interested in a
519 /// callsite, the currently active subscriber will be asked to filter that
520 /// callsite every time it creates a span. This will be the case until a new
521 /// subscriber expresses that it is `always` interested in the callsite.
523 pub fn sometimes() -> Self {
524 Interest(InterestKind
::Sometimes
)
527 /// Returns an `Interest` indicating the subscriber is always interested in
528 /// being notified about a callsite.
530 /// If any subscriber expresses that it is `always()` interested in a given
531 /// callsite, then the callsite will always be enabled.
533 pub fn always() -> Self {
534 Interest(InterestKind
::Always
)
537 /// Returns `true` if the subscriber is never interested in being notified
538 /// about this callsite.
540 pub fn is_never(&self) -> bool
{
541 matches
!(self.0, InterestKind
::Never
)
544 /// Returns `true` if the subscriber is sometimes interested in being notified
545 /// about this callsite.
547 pub fn is_sometimes(&self) -> bool
{
548 matches
!(self.0, InterestKind
::Sometimes
)
551 /// Returns `true` if the subscriber is always interested in being notified
552 /// about this callsite.
554 pub fn is_always(&self) -> bool
{
555 matches
!(self.0, InterestKind
::Always
)
558 /// Returns the common interest between these two Interests.
560 /// If both interests are the same, this propagates that interest.
561 /// Otherwise, if they differ, the result must always be
562 /// `Interest::sometimes` --- if the two subscribers differ in opinion, we
563 /// will have to ask the current subscriber what it thinks, no matter what.
564 pub(crate) fn and(self, rhs
: Interest
) -> Self {
568 Interest
::sometimes()
573 /// A no-op [`Subscriber`].
575 /// [`NoSubscriber`] implements the [`Subscriber`] trait by never being enabled,
576 /// never being interested in any callsite, and dropping all spans and events.
577 #[derive(Copy, Clone, Debug, Default)]
578 pub struct NoSubscriber(());
580 impl Subscriber
for NoSubscriber
{
582 fn register_callsite(&self, _
: &'
static Metadata
<'
static>) -> Interest
{
586 fn new_span(&self, _
: &span
::Attributes
<'_
>) -> span
::Id
{
587 span
::Id
::from_u64(0xDEAD)
590 fn event(&self, _event
: &Event
<'_
>) {}
592 fn record(&self, _span
: &span
::Id
, _values
: &span
::Record
<'_
>) {}
594 fn record_follows_from(&self, _span
: &span
::Id
, _follows
: &span
::Id
) {}
597 fn enabled(&self, _metadata
: &Metadata
<'_
>) -> bool
{
601 fn enter(&self, _span
: &span
::Id
) {}
602 fn exit(&self, _span
: &span
::Id
) {}
605 impl Subscriber
for Box
<dyn Subscriber
+ Send
+ Sync
+ '
static> {
607 fn register_callsite(&self, metadata
: &'
static Metadata
<'
static>) -> Interest
{
608 self.as_ref().register_callsite(metadata
)
612 fn enabled(&self, metadata
: &Metadata
<'_
>) -> bool
{
613 self.as_ref().enabled(metadata
)
617 fn max_level_hint(&self) -> Option
<LevelFilter
> {
618 self.as_ref().max_level_hint()
622 fn new_span(&self, span
: &span
::Attributes
<'_
>) -> span
::Id
{
623 self.as_ref().new_span(span
)
627 fn record(&self, span
: &span
::Id
, values
: &span
::Record
<'_
>) {
628 self.as_ref().record(span
, values
)
632 fn record_follows_from(&self, span
: &span
::Id
, follows
: &span
::Id
) {
633 self.as_ref().record_follows_from(span
, follows
)
637 fn event(&self, event
: &Event
<'_
>) {
638 self.as_ref().event(event
)
642 fn enter(&self, span
: &span
::Id
) {
643 self.as_ref().enter(span
)
647 fn exit(&self, span
: &span
::Id
) {
648 self.as_ref().exit(span
)
652 fn clone_span(&self, id
: &span
::Id
) -> span
::Id
{
653 self.as_ref().clone_span(id
)
657 fn try_close(&self, id
: span
::Id
) -> bool
{
658 self.as_ref().try_close(id
)
663 fn drop_span(&self, id
: span
::Id
) {
664 self.as_ref().try_close(id
);
668 fn current_span(&self) -> span
::Current
{
669 self.as_ref().current_span()
673 unsafe fn downcast_raw(&self, id
: TypeId
) -> Option
<*const ()> {
674 if id
== TypeId
::of
::<Self>() {
675 return Some(self as *const Self as *const _
);
678 self.as_ref().downcast_raw(id
)
682 impl Subscriber
for Arc
<dyn Subscriber
+ Send
+ Sync
+ '
static> {
684 fn register_callsite(&self, metadata
: &'
static Metadata
<'
static>) -> Interest
{
685 self.as_ref().register_callsite(metadata
)
689 fn enabled(&self, metadata
: &Metadata
<'_
>) -> bool
{
690 self.as_ref().enabled(metadata
)
694 fn max_level_hint(&self) -> Option
<LevelFilter
> {
695 self.as_ref().max_level_hint()
699 fn new_span(&self, span
: &span
::Attributes
<'_
>) -> span
::Id
{
700 self.as_ref().new_span(span
)
704 fn record(&self, span
: &span
::Id
, values
: &span
::Record
<'_
>) {
705 self.as_ref().record(span
, values
)
709 fn record_follows_from(&self, span
: &span
::Id
, follows
: &span
::Id
) {
710 self.as_ref().record_follows_from(span
, follows
)
714 fn event(&self, event
: &Event
<'_
>) {
715 self.as_ref().event(event
)
719 fn enter(&self, span
: &span
::Id
) {
720 self.as_ref().enter(span
)
724 fn exit(&self, span
: &span
::Id
) {
725 self.as_ref().exit(span
)
729 fn clone_span(&self, id
: &span
::Id
) -> span
::Id
{
730 self.as_ref().clone_span(id
)
734 fn try_close(&self, id
: span
::Id
) -> bool
{
735 self.as_ref().try_close(id
)
740 fn drop_span(&self, id
: span
::Id
) {
741 self.as_ref().try_close(id
);
745 fn current_span(&self) -> span
::Current
{
746 self.as_ref().current_span()
750 unsafe fn downcast_raw(&self, id
: TypeId
) -> Option
<*const ()> {
751 if id
== TypeId
::of
::<Self>() {
752 return Some(self as *const Self as *const _
);
755 self.as_ref().downcast_raw(id
)