-
Notifications
You must be signed in to change notification settings - Fork 94
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
feat(server): Add inbound filters functionality to dynamic sampling #920
Conversation
now we have matches_trace & matches_event
…into feat/dyn-sampling-filters
`parsed.sequence - default_sequence()` is always <= 0 when it is < 0 we get a panic since the value is unsigned (u64)
…ilters # Conflicts: # CHANGELOG.md
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.
Partial review of just the filter changes.
@@ -127,8 +201,11 @@ impl NotCondition { | |||
fn supported(&self) -> bool { | |||
self.inner.supported() | |||
} | |||
fn matches<T: FieldValueProvider>(&self, value_provider: &T) -> bool { | |||
!self.inner.matches(value_provider) | |||
fn matches_event(&self, event: &Event, ip_addr: Option<IpAddr>) -> bool { |
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.
In a follow-up, let's replace all these ip_addr
with RequestMeta:
- It's to be expected that we require more information about the request
ip_addr
doesn't specify which IP we want: the socket, the client, how to handle x-forwarded-for? This is what RequestMeta already solves for us.
pub struct CustomCondition { | ||
pub name: String, | ||
#[serde(default)] | ||
pub value: Value, |
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.
If we have generic options, why do we need value
here?
For a follow-up: It would be interesting to type out the custom conditions, since they are statically known in the code.
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.
to have a consistent structure that matches with the non custom operators.
For example:
{ "name": "event.releases", "op": "glob", "value": ["v1.1", "v2.*"]},
{ "name": "event.legacy_browsers", "op":"custom", "value":["ie8", "ie9"]},
The options are supposed to be used for configuring the operator (something like the ignore_case
from operator eq
).
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.
Understood. Once these are typed out it certainly looks better again. Let's keep like this, 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.
On another thought: It seems odd that we have options
but name
and value
special cased on the top, once everything is typed out. We can address this when typing out, though.
/// returns a match result | ||
fn get_custom_operator( | ||
name: &str, | ||
) -> fn(condition: &CustomCondition, slf: &Self, ip_addr: Option<IpAddr>) -> bool; |
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.
Probably also for a follow-up: Can we make it so that the Field provider inherently has access to the ip_addr
(or, better, the entire RequestMeta)? We could implement the trait on a type like this:
struct EventValueProvider<'a> {
event: &'a Annotated<Event>,
meta: &'a RequestMeta,
}
/// returns a match result | ||
fn get_custom_operator( | ||
name: &str, | ||
) -> fn(condition: &CustomCondition, slf: &Self, ip_addr: Option<IpAddr>) -> bool; |
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.
Q: Why not just run the custom condition inside the function?
fn match_custom(&self, condition: &CustomCondition, ip_addr: Option<IpAddr>) -> bool;
For a follow-up: Later down the road we need to refactor the value provider so that it can expose all fields needed by the custom rules via its get_value
interface.
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.
We could do that, it seemed wrong though.
The ValueProvider gives you information from the Event or Trace but doesn't also run
rules, anyway not feeling too strongly either way.
The presence of the custom operation in ValueProvider makes it quite a messy abstraction.
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.
Separate from this PR, could you compile a list of all attributes that we need access to for running the custom matchers?
} | ||
} | ||
|
||
#[test] | ||
/// test matching for various rules | ||
fn test_matches_events() { |
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.
In a follow-up, I would like to move all these tests to macro-based expansion. That way, each test runs in its own test function and we can see individual failures more easily.
We could also start adopting a test parameterization framework, but I'm still not convinced of that.
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.
While I like the idea in principle it would make debugging difficult/impossible and I like to have this option open.
I've been looking, a while back now, for a clean way to do parameterization of unit tests in Rust but all I found were frameworks that either used nightly builds or used some ugly macros.
If we can find a relatively clean way to do it while still being able to run a debugger I all for it.
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 can run and debug tests defined in macros just like any other test. Rust Analyzer even provides code lenses for debugging individual tests, for example as we do in relay-general/tests/test_fixtures.rs
:
Co-authored-by: Jan Michael Auer <[email protected]>
* master: (23 commits) feat(server): Add inbound filters functionality to dynamic sampling (#920) fix rule generation to new format (in tests) (#939) ref: Remove actix-web client, make reqwest the new http client (#938) fix(server): Reject empty envelopes with an explicit error (#937) fix(server): Ensure outcome data categories are numeric (#936) feat(stats): Add data category to TrackOutcome (#931) fix(pii): Make username pii-strippable (#935) build: Bump symbolic to 8.0.4 (#899) fix: Update to tokio 1.0 (#909) fix(pii): Make and/or work correctly with pii=maybe (#932) release: 21.2.0 release: 0.8.3 fix(build): Fix path to 3.7 (#930) build: drop python 2.7 support (#929) feat(protocol): Add snapshot to the stack trace interface (#927) test: Improve integration tests to reduce flakyness (#928) fix: Ignore false-positive lints from Clippy 1.50 (#926) feat(protocol): Add NSError to mechanism (#925) meta: Fix changelog meta(readme): Document development config for processing mode (#921) ...
* master: (42 commits) build: Switch to vendored openssl build (#914) feat(server): Add inbound filters functionality to dynamic sampling (#920) fix rule generation to new format (in tests) (#939) ref: Remove actix-web client, make reqwest the new http client (#938) fix(server): Reject empty envelopes with an explicit error (#937) fix(server): Ensure outcome data categories are numeric (#936) feat(stats): Add data category to TrackOutcome (#931) fix(pii): Make username pii-strippable (#935) build: Bump symbolic to 8.0.4 (#899) fix: Update to tokio 1.0 (#909) fix(pii): Make and/or work correctly with pii=maybe (#932) release: 21.2.0 release: 0.8.3 fix(build): Fix path to 3.7 (#930) build: drop python 2.7 support (#929) feat(protocol): Add snapshot to the stack trace interface (#927) test: Improve integration tests to reduce flakyness (#928) fix: Ignore false-positive lints from Clippy 1.50 (#926) feat(protocol): Add NSError to mechanism (#925) meta: Fix changelog ...
* master: (120 commits) fix(protocol): Deny backslashes in release names (#904) ref(server): Extract dynamic sampling functionality into own crate (#940) build: Switch to vendored openssl build (#914) feat(server): Add inbound filters functionality to dynamic sampling (#920) fix rule generation to new format (in tests) (#939) ref: Remove actix-web client, make reqwest the new http client (#938) fix(server): Reject empty envelopes with an explicit error (#937) fix(server): Ensure outcome data categories are numeric (#936) feat(stats): Add data category to TrackOutcome (#931) fix(pii): Make username pii-strippable (#935) build: Bump symbolic to 8.0.4 (#899) fix: Update to tokio 1.0 (#909) fix(pii): Make and/or work correctly with pii=maybe (#932) release: 21.2.0 release: 0.8.3 fix(build): Fix path to 3.7 (#930) build: drop python 2.7 support (#929) feat(protocol): Add snapshot to the stack trace interface (#927) test: Improve integration tests to reduce flakyness (#928) fix: Ignore false-positive lints from Clippy 1.50 (#926) ...
* master: test(general): Introduce macros for traversing Annotated (#826) fix(protocol): Deny backslashes in release names (#904) ref(server): Extract dynamic sampling functionality into own crate (#940) build: Switch to vendored openssl build (#914) feat(server): Add inbound filters functionality to dynamic sampling (#920) fix rule generation to new format (in tests) (#939) ref: Remove actix-web client, make reqwest the new http client (#938) fix(server): Reject empty envelopes with an explicit error (#937) fix(server): Ensure outcome data categories are numeric (#936) feat(stats): Add data category to TrackOutcome (#931) fix(pii): Make username pii-strippable (#935) build: Bump symbolic to 8.0.4 (#899) fix: Update to tokio 1.0 (#909) fix(pii): Make and/or work correctly with pii=maybe (#932) release: 21.2.0 release: 0.8.3 fix(build): Fix path to 3.7 (#930)
Adds dynamic sampling rules to support inbound filters functionality.
Covering the inbound filters functionality with dynamic sampling rules allows us to remove
inbound filters and present the user with only one concept and one configuration interface.