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`.
59 /// - [`clone_span`] is called every time a span ID is cloned, and [`try_close`]
60 /// is called when a span ID is dropped. By default, these functions do
61 /// nothing. However, they can be used to implement reference counting for
62 /// spans, allowing subscribers to free storage for span data and to determine
63 /// when a span has _closed_ permanently (rather than being exited).
64 /// Subscribers which store per-span data or which need to track span closures
65 /// should override these functions together.
67 /// [ID]: ../span/struct.Id.html
68 /// [`new_span`]: trait.Subscriber.html#method.new_span
69 /// [`register_callsite`]: trait.Subscriber.html#method.register_callsite
70 /// [`Interest`]: struct.Interest.html
71 /// [`enabled`]: trait.Subscriber.html#method.enabled
72 /// [`clone_span`]: trait.Subscriber.html#method.clone_span
73 /// [`try_close`]: trait.Subscriber.html#method.try_close
74 pub trait Subscriber
: '
static {
75 // === Span registry methods ==============================================
77 /// Registers a new callsite with this subscriber, returning whether or not
78 /// the subscriber is interested in being notified about the callsite.
80 /// By default, this function assumes that the subscriber's [filter]
81 /// represents an unchanging view of its interest in the callsite. However,
82 /// if this is not the case, subscribers may override this function to
83 /// indicate different interests, or to implement behaviour that should run
84 /// once for every callsite.
86 /// This function is guaranteed to be called at least once per callsite on
87 /// every active subscriber. The subscriber may store the keys to fields it
88 /// cares about in order to reduce the cost of accessing fields by name,
89 /// preallocate storage for that callsite, or perform any other actions it
90 /// wishes to perform once for each callsite.
92 /// The subscriber should then return an [`Interest`], indicating
93 /// whether it is interested in being notified about that callsite in the
94 /// future. This may be `Always` indicating that the subscriber always
95 /// wishes to be notified about the callsite, and its filter need not be
96 /// re-evaluated; `Sometimes`, indicating that the subscriber may sometimes
97 /// care about the callsite but not always (such as when sampling), or
98 /// `Never`, indicating that the subscriber never wishes to be notified about
99 /// that callsite. If all active subscribers return `Never`, a callsite will
100 /// never be enabled unless a new subscriber expresses interest in it.
102 /// `Subscriber`s which require their filters to be run every time an event
103 /// occurs or a span is entered/exited should return `Interest::sometimes`.
104 /// If a subscriber returns `Interest::sometimes`, then its [`enabled`] method
105 /// will be called every time an event or span is created from that callsite.
107 /// For example, suppose a sampling subscriber is implemented by
108 /// incrementing a counter every time `enabled` is called and only returning
109 /// `true` when the counter is divisible by a specified sampling rate. If
110 /// that subscriber returns `Interest::always` from `register_callsite`, then
111 /// the filter will not be re-evaluated once it has been applied to a given
112 /// set of metadata. Thus, the counter will not be incremented, and the span
113 /// or event that corresponds to the metadata will never be `enabled`.
115 /// `Subscriber`s that need to change their filters occasionally should call
116 /// [`rebuild_interest_cache`] to re-evaluate `register_callsite` for all
119 /// Similarly, if a `Subscriber` has a filtering strategy that can be
120 /// changed dynamically at runtime, it would need to re-evaluate that filter
121 /// if the cached results have changed.
123 /// A subscriber which manages fanout to multiple other subscribers
124 /// should proxy this decision to all of its child subscribers,
125 /// returning `Interest::never` only if _all_ such children return
126 /// `Interest::never`. If the set of subscribers to which spans are
127 /// broadcast may change dynamically, the subscriber should also never
128 /// return `Interest::Never`, as a new subscriber may be added that _is_
132 /// This function may be called again when a new subscriber is created or
133 /// when the registry is invalidated.
135 /// If a subscriber returns `Interest::never` for a particular callsite, it
136 /// _may_ still see spans and events originating from that callsite, if
137 /// another subscriber expressed interest in it.
139 /// [filter]: #method.enabled
140 /// [metadata]: ../metadata/struct.Metadata.html
141 /// [`Interest`]: struct.Interest.html
142 /// [`enabled`]: #method.enabled
143 /// [`rebuild_interest_cache`]: ../callsite/fn.rebuild_interest_cache.html
144 fn register_callsite(&self, metadata
: &'
static Metadata
<'
static>) -> Interest
{
145 if self.enabled(metadata
) {
152 /// Returns true if a span or event with the specified [metadata] would be
155 /// By default, it is assumed that this filter needs only be evaluated once
156 /// for each callsite, so it is called by [`register_callsite`] when each
157 /// callsite is registered. The result is used to determine if the subscriber
158 /// is always [interested] or never interested in that callsite. This is intended
159 /// primarily as an optimization, so that expensive filters (such as those
160 /// involving string search, et cetera) need not be re-evaluated.
162 /// However, if the subscriber's interest in a particular span or event may
163 /// change, or depends on contexts only determined dynamically at runtime,
164 /// then the `register_callsite` method should be overridden to return
165 /// [`Interest::sometimes`]. In that case, this function will be called every
166 /// time that span or event occurs.
168 /// [metadata]: ../metadata/struct.Metadata.html
169 /// [interested]: struct.Interest.html
170 /// [`Interest::sometimes`]: struct.Interest.html#method.sometimes
171 /// [`register_callsite`]: #method.register_callsite
172 fn enabled(&self, metadata
: &Metadata
<'_
>) -> bool
;
174 /// Returns the highest [verbosity level][level] that this `Subscriber` will
175 /// enable, or `None`, if the subscriber does not implement level-based
176 /// filtering or chooses not to implement this method.
178 /// If this method returns a [`Level`][level], it will be used as a hint to
179 /// determine the most verbose level that will be enabled. This will allow
180 /// spans and events which are more verbose than that level to be skipped
181 /// more efficiently. Subscribers which perform filtering are strongly
182 /// encouraged to provide an implementation of this method.
184 /// If the maximum level the subscriber will enable can change over the
185 /// course of its lifetime, it is free to return a different value from
186 /// multiple invocations of this method. However, note that changes in the
187 /// maximum level will **only** be reflected after the callsite [`Interest`]
188 /// cache is rebuilt, by calling the [`callsite::rebuild_interest_cache`][rebuild]
189 /// function. Therefore, if the subscriber will change the value returned by
190 /// this method, it is responsible for ensuring that
191 /// [`rebuild_interest_cache`][rebuild] is called after the value of the max
194 /// [level]: ../struct.Level.html
195 /// [`Interest`]: struct.Interest.html
196 /// [rebuild]: ../callsite/fn.rebuild_interest_cache.html
197 fn max_level_hint(&self) -> Option
<LevelFilter
> {
201 /// Visit the construction of a new span, returning a new [span ID] for the
202 /// span being constructed.
204 /// The provided [`Attributes`] contains any field values that were provided
205 /// when the span was created. The subscriber may pass a [visitor] to the
206 /// `Attributes`' [`record` method] to record these values.
208 /// IDs are used to uniquely identify spans and events within the context of a
209 /// subscriber, so span equality will be based on the returned ID. Thus, if
210 /// the subscriber wishes for all spans with the same metadata to be
211 /// considered equal, it should return the same ID every time it is given a
212 /// particular set of metadata. Similarly, if it wishes for two separate
213 /// instances of a span with the same metadata to *not* be equal, it should
214 /// return a distinct ID every time this function is called, regardless of
217 /// Note that the subscriber is free to assign span IDs based on whatever
218 /// scheme it sees fit. Any guarantees about uniqueness, ordering, or ID
219 /// reuse are left up to the subscriber implementation to determine.
221 /// [span ID]: ../span/struct.Id.html
222 /// [`Attributes`]: ../span/struct.Attributes.html
223 /// [visitor]: ../field/trait.Visit.html
224 /// [`record` method]: ../span/struct.Attributes.html#method.record
225 fn new_span(&self, span
: &span
::Attributes
<'_
>) -> span
::Id
;
227 // === Notification methods ===============================================
229 /// Record a set of values on a span.
231 /// This method will be invoked when value is recorded on a span.
232 /// Recording multiple values for the same field is possible,
233 /// but the actual behaviour is defined by the subscriber implementation.
235 /// Keep in mind that a span might not provide a value
236 /// for each field it declares.
238 /// The subscriber is expected to provide a [visitor] to the `Record`'s
239 /// [`record` method] in order to record the added values.
242 /// "foo = 3" will be recorded when [`record`] is called on the
243 /// `Attributes` passed to `new_span`.
244 /// Since values are not provided for the `bar` and `baz` fields,
245 /// the span's `Metadata` will indicate that it _has_ those fields,
246 /// but values for them won't be recorded at this time.
249 /// # use tracing::span;
251 /// let mut span = span!("my_span", foo = 3, bar, baz);
253 /// // `Subscriber::record` will be called with a `Record`
254 /// // containing "bar = false"
255 /// span.record("bar", &false);
257 /// // `Subscriber::record` will be called with a `Record`
258 /// // containing "baz = "a string""
259 /// span.record("baz", &"a string");
262 /// [visitor]: ../field/trait.Visit.html
263 /// [`record`]: ../span/struct.Attributes.html#method.record
264 /// [`record` method]: ../span/struct.Record.html#method.record
265 fn record(&self, span
: &span
::Id
, values
: &span
::Record
<'_
>);
267 /// Adds an indication that `span` follows from the span with the id
270 /// This relationship differs somewhat from the parent-child relationship: a
271 /// span may have any number of prior spans, rather than a single one; and
272 /// spans are not considered to be executing _inside_ of the spans they
273 /// follow from. This means that a span may close even if subsequent spans
274 /// that follow from it are still open, and time spent inside of a
275 /// subsequent span should not be included in the time its precedents were
276 /// executing. This is used to model causal relationships such as when a
277 /// single future spawns several related background tasks, et cetera.
279 /// If the subscriber has spans corresponding to the given IDs, it should
280 /// record this relationship in whatever way it deems necessary. Otherwise,
281 /// if one or both of the given span IDs do not correspond to spans that the
282 /// subscriber knows about, or if a cyclical relationship would be created
283 /// (i.e., some span _a_ which proceeds some other span _b_ may not also
284 /// follow from _b_), it may silently do nothing.
285 fn record_follows_from(&self, span
: &span
::Id
, follows
: &span
::Id
);
287 /// Records that an [`Event`] has occurred.
289 /// This method will be invoked when an Event is constructed by
290 /// the `Event`'s [`dispatch` method]. For example, this happens internally
291 /// when an event macro from `tracing` is called.
293 /// The key difference between this method and `record` is that `record` is
294 /// called when a value is recorded for a field defined by a span,
295 /// while `event` is called when a new event occurs.
297 /// The provided `Event` struct contains any field values attached to the
298 /// event. The subscriber may pass a [visitor] to the `Event`'s
299 /// [`record` method] to record these values.
301 /// [`Event`]: ../event/struct.Event.html
302 /// [visitor]: ../field/trait.Visit.html
303 /// [`record` method]: ../event/struct.Event.html#method.record
304 /// [`dispatch` method]: ../event/struct.Event.html#method.dispatch
305 fn event(&self, event
: &Event
<'_
>);
307 /// Records that a span has been entered.
309 /// When entering a span, this method is called to notify the subscriber
310 /// that the span has been entered. The subscriber is provided with the
311 /// [span ID] of the entered span, and should update any internal state
312 /// tracking the current span accordingly.
314 /// [span ID]: ../span/struct.Id.html
315 fn enter(&self, span
: &span
::Id
);
317 /// Records that a span has been exited.
319 /// When exiting a span, this method is called to notify the subscriber
320 /// that the span has been exited. The subscriber is provided with the
321 /// [span ID] of the exited span, and should update any internal state
322 /// tracking the current span accordingly.
324 /// Exiting a span does not imply that the span will not be re-entered.
326 /// [span ID]: ../span/struct.Id.html
327 fn exit(&self, span
: &span
::Id
);
329 /// Notifies the subscriber that a [span ID] has been cloned.
331 /// This function is guaranteed to only be called with span IDs that were
332 /// returned by this subscriber's `new_span` function.
334 /// Note that the default implementation of this function this is just the
335 /// identity function, passing through the identifier. However, it can be
336 /// used in conjunction with [`try_close`] to track the number of handles
337 /// capable of `enter`ing a span. When all the handles have been dropped
338 /// (i.e., `try_close` has been called one more time than `clone_span` for a
339 /// given ID), the subscriber may assume that the span will not be entered
340 /// again. It is then free to deallocate storage for data associated with
341 /// that span, write data from that span to IO, and so on.
343 /// For more unsafe situations, however, if `id` is itself a pointer of some
344 /// kind this can be used as a hook to "clone" the pointer, depending on
345 /// what that means for the specified pointer.
347 /// [span ID]: ../span/struct.Id.html
348 /// [`try_close`]: trait.Subscriber.html#method.try_close
349 fn clone_span(&self, id
: &span
::Id
) -> span
::Id
{
353 /// **This method is deprecated.**
355 /// Using `drop_span` may result in subscribers composed using
356 /// `tracing-subscriber` crate's `Layer` trait from observing close events.
357 /// Use [`try_close`] instead.
359 /// The default implementation of this function does nothing.
361 /// [`try_close`]: trait.Subscriber.html#method.try_close
362 #[deprecated(since = "0.1.2", note = "use `Subscriber::try_close` instead")]
363 fn drop_span(&self, _id
: span
::Id
) {}
365 /// Notifies the subscriber that a [span ID] has been dropped, and returns
366 /// `true` if there are now 0 IDs that refer to that span.
368 /// Higher-level libraries providing functionality for composing multiple
369 /// subscriber implementations may use this return value to notify any
370 /// "layered" subscribers that this subscriber considers the span closed.
372 /// The default implementation of this method calls the subscriber's
373 /// [`drop_span`] method and returns `false`. This means that, unless the
374 /// subscriber overrides the default implementation, close notifications
375 /// will never be sent to any layered subscribers. In general, if the
376 /// subscriber tracks reference counts, this method should be implemented,
377 /// rather than `drop_span`.
379 /// This function is guaranteed to only be called with span IDs that were
380 /// returned by this subscriber's `new_span` function.
382 /// It's guaranteed that if this function has been called once more than the
383 /// number of times `clone_span` was called with the same `id`, then no more
384 /// handles that can enter the span with that `id` exist. This means that it
385 /// can be used in conjunction with [`clone_span`] to track the number of
386 /// handles capable of `enter`ing a span. When all the handles have been
387 /// dropped (i.e., `try_close` has been called one more time than
388 /// `clone_span` for a given ID), the subscriber may assume that the span
389 /// will not be entered again, and should return `true`. It is then free to
390 /// deallocate storage for data associated with that span, write data from
391 /// that span to IO, and so on.
393 /// **Note**: since this function is called when spans are dropped,
394 /// implementations should ensure that they are unwind-safe. Panicking from
395 /// inside of a `try_close` function may cause a double panic, if the span
396 /// was dropped due to a thread unwinding.
398 /// [span ID]: ../span/struct.Id.html
399 /// [`clone_span`]: trait.Subscriber.html#method.clone_span
400 /// [`drop_span`]: trait.Subscriber.html#method.drop_span
401 fn try_close(&self, id
: span
::Id
) -> bool
{
407 /// Returns a type representing this subscriber's view of the current span.
409 /// If subscribers track a current span, they should override this function
410 /// to return [`Current::new`] if the thread from which this method is
411 /// called is inside a span, or [`Current::none`] if the thread is not
414 /// By default, this returns a value indicating that the subscriber
415 /// does **not** track what span is current. If the subscriber does not
416 /// implement a current span, it should not override this method.
418 /// [`Current::new`]: ../span/struct.Current.html#tymethod.new
419 /// [`Current::none`]: ../span/struct.Current.html#tymethod.none
420 fn current_span(&self) -> span
::Current
{
421 span
::Current
::unknown()
424 // === Downcasting methods ================================================
426 /// If `self` is the same type as the provided `TypeId`, returns an untyped
427 /// `*const` pointer to that type. Otherwise, returns `None`.
429 /// If you wish to downcast a `Subscriber`, it is strongly advised to use
430 /// the safe API provided by [`downcast_ref`] instead.
432 /// This API is required for `downcast_raw` to be a trait method; a method
433 /// signature like [`downcast_ref`] (with a generic type parameter) is not
434 /// object-safe, and thus cannot be a trait method for `Subscriber`. This
435 /// means that if we only exposed `downcast_ref`, `Subscriber`
436 /// implementations could not override the downcasting behavior
438 /// This method may be overridden by "fan out" or "chained" subscriber
439 /// implementations which consist of multiple composed types. Such
440 /// subscribers might allow `downcast_raw` by returning references to those
441 /// component if they contain components with the given `TypeId`.
445 /// The [`downcast_ref`] method expects that the pointer returned by
446 /// `downcast_raw` is non-null and points to a valid instance of the type
447 /// with the provided `TypeId`. Failure to ensure this will result in
448 /// undefined behaviour, so implementing `downcast_raw` is unsafe.
450 /// [`downcast_ref`]: #method.downcast_ref
451 unsafe fn downcast_raw(&self, id
: TypeId
) -> Option
<*const ()> {
452 if id
== TypeId
::of
::<Self>() {
453 Some(self as *const Self as *const ())
460 impl dyn Subscriber
{
461 /// Returns `true` if this `Subscriber` is the same type as `T`.
462 pub fn is
<T
: Any
>(&self) -> bool
{
463 self.downcast_ref
::<T
>().is_some()
466 /// Returns some reference to this `Subscriber` value if it is of type `T`,
467 /// or `None` if it isn't.
468 pub fn downcast_ref
<T
: Any
>(&self) -> Option
<&T
> {
470 let raw
= self.downcast_raw(TypeId
::of
::<T
>())?
;
474 Some(&*(raw
as *const _
))
480 /// Indicates a [`Subscriber`]'s interest in a particular callsite.
482 /// `Subscriber`s return an `Interest` from their [`register_callsite`] methods
483 /// in order to determine whether that span should be enabled or disabled.
485 /// [`Subscriber`]: ../trait.Subscriber.html
486 /// [`register_callsite`]: ../trait.Subscriber.html#method.register_callsite
487 #[derive(Clone, Debug)]
488 pub struct Interest(InterestKind
);
490 #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
498 /// Returns an `Interest` indicating that the subscriber is never interested
499 /// in being notified about a callsite.
501 /// If all active subscribers are `never()` interested in a callsite, it will
502 /// be completely disabled unless a new subscriber becomes active.
504 pub fn never() -> Self {
505 Interest(InterestKind
::Never
)
508 /// Returns an `Interest` indicating the subscriber is sometimes interested
509 /// in being notified about a callsite.
511 /// If all active subscribers are `sometimes` or `never` interested in a
512 /// callsite, the currently active subscriber will be asked to filter that
513 /// callsite every time it creates a span. This will be the case until a new
514 /// subscriber expresses that it is `always` interested in the callsite.
516 pub fn sometimes() -> Self {
517 Interest(InterestKind
::Sometimes
)
520 /// Returns an `Interest` indicating the subscriber is always interested in
521 /// being notified about a callsite.
523 /// If any subscriber expresses that it is `always()` interested in a given
524 /// callsite, then the callsite will always be enabled.
526 pub fn always() -> Self {
527 Interest(InterestKind
::Always
)
530 /// Returns `true` if the subscriber is never interested in being notified
531 /// about this callsite.
533 pub fn is_never(&self) -> bool
{
534 matches
!(self.0, InterestKind
::Never
)
537 /// Returns `true` if the subscriber is sometimes interested in being notified
538 /// about this callsite.
540 pub fn is_sometimes(&self) -> bool
{
541 matches
!(self.0, InterestKind
::Sometimes
)
544 /// Returns `true` if the subscriber is always interested in being notified
545 /// about this callsite.
547 pub fn is_always(&self) -> bool
{
548 matches
!(self.0, InterestKind
::Always
)
551 /// Returns the common interest between these two Interests.
553 /// If both interests are the same, this propagates that interest.
554 /// Otherwise, if they differ, the result must always be
555 /// `Interest::sometimes` --- if the two subscribers differ in opinion, we
556 /// will have to ask the current subscriber what it thinks, no matter what.
557 pub(crate) fn and(self, rhs
: Interest
) -> Self {
561 Interest
::sometimes()
566 /// A no-op [`Subscriber`].
568 /// [`NoSubscriber`] implements the [`Subscriber`] trait by never being enabled,
569 /// never being interested in any callsite, and dropping all spans and events.
570 #[derive(Copy, Clone, Debug, Default)]
571 pub struct NoSubscriber(());
573 impl Subscriber
for NoSubscriber
{
575 fn register_callsite(&self, _
: &'
static Metadata
<'
static>) -> Interest
{
579 fn new_span(&self, _
: &span
::Attributes
<'_
>) -> span
::Id
{
580 span
::Id
::from_u64(0xDEAD)
583 fn event(&self, _event
: &Event
<'_
>) {}
585 fn record(&self, _span
: &span
::Id
, _values
: &span
::Record
<'_
>) {}
587 fn record_follows_from(&self, _span
: &span
::Id
, _follows
: &span
::Id
) {}
590 fn enabled(&self, _metadata
: &Metadata
<'_
>) -> bool
{
594 fn enter(&self, _span
: &span
::Id
) {}
595 fn exit(&self, _span
: &span
::Id
) {}
598 impl Subscriber
for Box
<dyn Subscriber
+ Send
+ Sync
+ '
static> {
600 fn register_callsite(&self, metadata
: &'
static Metadata
<'
static>) -> Interest
{
601 self.as_ref().register_callsite(metadata
)
605 fn enabled(&self, metadata
: &Metadata
<'_
>) -> bool
{
606 self.as_ref().enabled(metadata
)
610 fn max_level_hint(&self) -> Option
<LevelFilter
> {
611 self.as_ref().max_level_hint()
615 fn new_span(&self, span
: &span
::Attributes
<'_
>) -> span
::Id
{
616 self.as_ref().new_span(span
)
620 fn record(&self, span
: &span
::Id
, values
: &span
::Record
<'_
>) {
621 self.as_ref().record(span
, values
)
625 fn record_follows_from(&self, span
: &span
::Id
, follows
: &span
::Id
) {
626 self.as_ref().record_follows_from(span
, follows
)
630 fn event(&self, event
: &Event
<'_
>) {
631 self.as_ref().event(event
)
635 fn enter(&self, span
: &span
::Id
) {
636 self.as_ref().enter(span
)
640 fn exit(&self, span
: &span
::Id
) {
641 self.as_ref().exit(span
)
645 fn clone_span(&self, id
: &span
::Id
) -> span
::Id
{
646 self.as_ref().clone_span(id
)
650 fn try_close(&self, id
: span
::Id
) -> bool
{
651 self.as_ref().try_close(id
)
656 fn drop_span(&self, id
: span
::Id
) {
657 self.as_ref().try_close(id
);
661 fn current_span(&self) -> span
::Current
{
662 self.as_ref().current_span()
666 unsafe fn downcast_raw(&self, id
: TypeId
) -> Option
<*const ()> {
667 if id
== TypeId
::of
::<Self>() {
668 return Some(self as *const Self as *const _
);
671 self.as_ref().downcast_raw(id
)
675 impl Subscriber
for Arc
<dyn Subscriber
+ Send
+ Sync
+ '
static> {
677 fn register_callsite(&self, metadata
: &'
static Metadata
<'
static>) -> Interest
{
678 self.as_ref().register_callsite(metadata
)
682 fn enabled(&self, metadata
: &Metadata
<'_
>) -> bool
{
683 self.as_ref().enabled(metadata
)
687 fn max_level_hint(&self) -> Option
<LevelFilter
> {
688 self.as_ref().max_level_hint()
692 fn new_span(&self, span
: &span
::Attributes
<'_
>) -> span
::Id
{
693 self.as_ref().new_span(span
)
697 fn record(&self, span
: &span
::Id
, values
: &span
::Record
<'_
>) {
698 self.as_ref().record(span
, values
)
702 fn record_follows_from(&self, span
: &span
::Id
, follows
: &span
::Id
) {
703 self.as_ref().record_follows_from(span
, follows
)
707 fn event(&self, event
: &Event
<'_
>) {
708 self.as_ref().event(event
)
712 fn enter(&self, span
: &span
::Id
) {
713 self.as_ref().enter(span
)
717 fn exit(&self, span
: &span
::Id
) {
718 self.as_ref().exit(span
)
722 fn clone_span(&self, id
: &span
::Id
) -> span
::Id
{
723 self.as_ref().clone_span(id
)
727 fn try_close(&self, id
: span
::Id
) -> bool
{
728 self.as_ref().try_close(id
)
733 fn drop_span(&self, id
: span
::Id
) {
734 self.as_ref().try_close(id
);
738 fn current_span(&self) -> span
::Current
{
739 self.as_ref().current_span()
743 unsafe fn downcast_raw(&self, id
: TypeId
) -> Option
<*const ()> {
744 if id
== TypeId
::of
::<Self>() {
745 return Some(self as *const Self as *const _
);
748 self.as_ref().downcast_raw(id
)