From 60f816b9a78bbc23fc4d3a30392f0ef5c33a0c26 Mon Sep 17 00:00:00 2001 From: Folyd Date: Thu, 24 Jun 2021 03:14:39 +0800 Subject: [PATCH] subscriber: explain why we always call `inner.register_callsite()` before if statement (#1433) * subscriber: explain why we always call `inner.register_callsite()` before if statement * Apply suggestions from code review Co-authored-by: Eliza Weisman --- tracing-subscriber/src/subscribe.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tracing-subscriber/src/subscribe.rs b/tracing-subscriber/src/subscribe.rs index aebe27809a..608d59273a 100644 --- a/tracing-subscriber/src/subscribe.rs +++ b/tracing-subscriber/src/subscribe.rs @@ -589,6 +589,9 @@ where return outer; } + // The intention behind calling `inner.register_callsite()` before the if statement + // is to ensure that the inner subscriber is informed that the callsite exists + // regardless of the outer subscriber's filtering decision. let inner = self.inner.register_callsite(metadata); if outer.is_sometimes() { // if this interest is "sometimes", return "sometimes" to ensure that @@ -715,6 +718,9 @@ where return outer; } + // The intention behind calling `inner.register_callsite()` before the if statement + // is to ensure that the inner subscriber is informed that the callsite exists + // regardless of the outer subscriber's filtering decision. let inner = self.inner.register_callsite(metadata); if outer.is_sometimes() { // if this interest is "sometimes", return "sometimes" to ensure that