Skip to content

Commit

Permalink
subscriber: explain why we always call inner.register_callsite() be…
Browse files Browse the repository at this point in the history
…fore 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 <[email protected]>
  • Loading branch information
Folyd and hawkw authored Jun 23, 2021
1 parent 4af08fa commit 60f816b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tracing-subscriber/src/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 60f816b

Please sign in to comment.