Skip to content

Commit

Permalink
Properly call Collect::event_enabled in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
CAD97 committed Apr 11, 2022
1 parent df4b068 commit d9591bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tracing-core/src/collect.rs
Expand Up @@ -642,6 +642,11 @@ impl Collect for alloc::boxed::Box<dyn Collect + Send + Sync + 'static> {
self.as_ref().record_follows_from(span, follows)
}

#[inline]
fn event_enabled(&self, event: &Event<'_>) -> bool {
self.as_ref().event_enabled(event)
}

#[inline]
fn event(&self, event: &Event<'_>) {
self.as_ref().event(event)
Expand Down Expand Up @@ -713,6 +718,11 @@ impl Collect for alloc::sync::Arc<dyn Collect + Send + Sync + 'static> {
self.as_ref().record_follows_from(span, follows)
}

#[inline]
fn event_enabled(&self, event: &Event<'_>) -> bool {
self.as_ref().event_enabled(event)
}

#[inline]
fn event(&self, event: &Event<'_>) {
self.as_ref().event(event)
Expand Down
5 changes: 4 additions & 1 deletion tracing-core/src/dispatch.rs
Expand Up @@ -682,7 +682,10 @@ impl Dispatch {
/// [`event`]: super::collect::Collect::event
#[inline]
pub fn event(&self, event: &Event<'_>) {
self.collector().event(event)
let collector = self.collector();
if collector.event_enabled(event) {
collector.event(event);
}
}

/// Records that a span has been can_enter.
Expand Down
5 changes: 5 additions & 0 deletions tracing-subscriber/src/fmt/mod.rs
Expand Up @@ -393,6 +393,11 @@ where
self.inner.record_follows_from(span, follows)
}

#[inline]
fn event_enabled(&self, event: &Event<'_>) -> bool {
self.inner.event_enabled(event)
}

#[inline]
fn event(&self, event: &Event<'_>) {
self.inner.event(event);
Expand Down

0 comments on commit d9591bd

Please sign in to comment.