File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
tracing-subscriber/src/filter/env Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -297,6 +297,19 @@ impl<S: Subscriber> Layer<S> for EnvFilter {
297297 // if not, we can avoid the thread local access + iterating over the
298298 // spans in the current scope.
299299 if self . has_dynamics && self . dynamics . max_level >= * level {
300+ if metadata. is_span ( ) {
301+ // If the metadata is a span, see if we care about its callsite.
302+ let enabled_by_cs = self
303+ . by_cs
304+ . read ( )
305+ . ok ( )
306+ . map ( |by_cs| by_cs. contains_key ( & metadata. callsite ( ) ) )
307+ . unwrap_or ( false ) ;
308+ if enabled_by_cs {
309+ return true ;
310+ }
311+ }
312+
300313 let enabled_by_scope = SCOPE . with ( |scope| {
301314 for filter in scope. borrow ( ) . iter ( ) {
302315 if filter >= level {
@@ -314,9 +327,6 @@ impl<S: Subscriber> Layer<S> for EnvFilter {
314327 if self . statics . max_level >= * level {
315328 // Otherwise, fall back to checking if the callsite is
316329 // statically enabled.
317- // TODO(eliza): we *might* want to check this only if the `log`
318- // feature is enabled, since if this is a `tracing` event with a
319- // real callsite, it would already have been statically enabled...
320330 return self . statics . enabled ( metadata) ;
321331 }
322332
You can’t perform that action at this time.
0 commit comments