-
Notifications
You must be signed in to change notification settings - Fork 884
Clarify filter.not() w.r.t. event_enabled
#2251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -403,11 +403,56 @@ where | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// If the wrapped filter would enable a span or event, it will be disabled. If | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// it would disable a span or event, that span or event will be enabled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// This inverts the values returned by the [`enabled`] and [`callsite_enabled`] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// methods on the wrapped filter; it does *not* invert [`event_enabled`], as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// implementing that method is optional, and filters which do not implement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// filtering on event field values will return `true` even for events that their | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// [`enabled`] method would disable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// The wrapped filter's [`callsite_enabled`] and [`enabled`] are inverted, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// but [`event_enabled`] is ignored, as most filters always return `true` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// from `event_enabled` and rely on `[callsite_]enabled` for filtering. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Essentially, where a normal filter is roughly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CAD97 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// ```ignore (psuedo-code) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
hawkw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// // for spans | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// match callsite_enabled() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// ALWAYS => on_span(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// SOMETIMES => if enabled() { on_span() }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// NEVER => (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// // for events | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// match callsite_enabled() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// ALWAYS => on_event(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// SOMETIMES => if enabled() && event_enabled() { on_event() }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// NEVER => (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// an inverted filter is roughly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CAD97 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// ```ignore (psuedo-code) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
hawkw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// // for spans | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// match callsite_enabled() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// ALWAYS => (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// SOMETIMES => if !enabled() { on_span() }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// NEVER => on_span(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// // for events | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// match callsite_enabled() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// ALWAYS => (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// SOMETIMES => if !enabled() { on_event() }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// NEVER => on_event(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
F::callsite_enabled |
F::enabled |
S::enabled |
F::event_enabled |
S::event_enabled |
lifecycle callbacks |
|---|---|---|---|---|---|
ALWAYS |
✗ | ✗ | ✗ | ✗ | ✓ |
NEVER |
✗ | ✗ | ✗ | ✗ | ✗ |
SOMETIMES |
true |
✓ | ✗ | ✗ | ✓ (span) |
SOMETIMES |
true |
✓ | true |
✓ | ✓ (event) |
SOMETIMES |
true |
✓ | false |
✗ | ✗ (event) |
SOMETIMES |
false |
✗ | ✗ | ✗ | ✗ |
Not
F::callsite_enabled |
F::enabled |
S::enabled |
F::event_enabled |
S::event_enabled |
lifecycle callbacks |
|---|---|---|---|---|---|
ALWAYS |
✗ | ✗ | ✗ | ✗ | ✗ |
NEVER |
✗ | ✗ | ✗ | ✗ | ✓ |
SOMETIMES |
true |
✗ | ✗ | ✗ | ✗ |
SOMETIMES |
false |
✓ | ✗ | ✗ | ✓ (span) |
SOMETIMES |
false |
✓ | ✗ | ✓ | ✓ (event) |
Pure logical filter inverse without time travel
F::callsite_enabled |
F::enabled |
S::enabled |
F::event_enabled |
S::event_enabled |
lifecycle callbacks |
|---|---|---|---|---|---|
ALWAYS |
✗ | ✗ | ✗ | ✗ | ✗ |
NEVER |
✗ | ✗ | ✗ | ✗ | ✓ |
SOMETIMES |
true |
✗ | ✗ | ✗ | ✗ (span) |
SOMETIMES |
true |
✓ | true |
✗ | ✗ (event) |
SOMETIMES |
true |
✓ | false |
✓ | ✓ (event) |
SOMETIMES |
false |
✓ | ✗ | ✗ | ✓ (span) |
SOMETIMES |
false |
✓ | ✗ | ✓ | ✓ (event) |
I wish I could give a nice visual diff between the tables, but this'll have to do: diff Not to "logical":
| `F::callsite_enabled` | `F::enabled` | `S::enabled` | `F::event_enabled` | `S::event_enabled` | lifecycle callbacks |
| :-: | :-: | :-: | :-: | :-: | :-: |
| `ALWAYS` | ✗ | ✗ | ✗ | ✗ | ✗ |
| `NEVER` | ✗ | ✗ | ✗ | ✗ | ✓ |
-| `SOMETIMES` | `true` | ✗ | ✗ | ✗ | ✗ |
+| `SOMETIMES` | `true` | ✗ | ✗ | ✗ | ✗ (span) |
+| `SOMETIMES` | `true` | ✓ | `true` | ✗ | ✗ (event) |
+| `SOMETIMES` | `true` | ✓ | `false` | ✓ | ✓ (event) |
| `SOMETIMES` | `false` | ✓ | ✗ | ✗ | ✓ (span) |
| `SOMETIMES` | `false` | ✓ | ✗ | ✓ | ✓ (event) |There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, yeah, that's...not great. i'm fine with the pseudocode instead, then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(It's worth noting that the pseudocode doesn't contain the S::* information from the tables, so for a fair comparison drop those two columns. But yeah, communicating short circuiting in a table is hard.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mentioned thinking maybe we should've made event_enabled return Option<bool>; the "correct" behavior I think would've been for (a time machine and) enabled to also return Interest, then iff that returns a sometimes() calling span_enabled/event_enabled for a final determination.
So roughly
- Cached once per callsite,
callsite_enabled. - Each time
span!is entered:- if callsite enabled always: Evaluate fields. Return active span.
- if callsite enabled sometimes:
- Check
enabled. - if
enabledalways: Evaluate fields. Return active span. - if
enabledsometimes:- Evaluate fields.
- If
span_enabled: Return active span.
- Check
- Return disabled span.
- Each time
event!is entered:- if callsite enabled always: Evaluate fields. Emit event.
- if callsite enabled sometimes:
- Check
enabled. - If
enabledalways: Evaluate fields. Emit event. - If
enabledsometimes:- Evaluate fields.
- If
event_enabled: Emit event.
- Check
In terms of signatures,
Collectregister_callsite(&self, &Metadata) -> Interestenabled(&self, &Metadata) -> Interestspan_enabled(&self, &Attributes) -> boolevent_enabled(&self, &Attributes) -> bool
Subscribe(but only local filtering)register_callsite(&self, &Metadata) -> Interestenabled(&self, &Metadata, &Context) -> Interestspan_enabled(&self, &Attributes, &Context) -> boolevent_enabled(&self, &Attributes, &Context) -> bool
- Per-layer filtering is done by layering
Subscribein a tree fashion.
(I'd personally also say that the enabled functions not being called when !interest.is_sometimes() is purely an optimization and you are not allowed to rely on this being true. This isn't necessary, but it's imho easier to reason about for wrapping collectors/filters.)
(Yes, there's complexity in the system I'm not fully aware of that probably makes that too simple.)
Uh oh!
There was an error while loading. Please reload this page.