-
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
ref(filters): Access fields through trait #3397
Conversation
if event.ty.value() != Some(&EventType::Transaction) { | ||
return false; | ||
} |
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.
This check moved to the trait implementation.
use relay_event_schema::protocol::{Csp, Event, EventType, Exception, LogEntry, Values}; | ||
|
||
/// A data item to which filters can be applied. | ||
pub trait Filterable { |
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.
I'm open for ideas on how to name this trait.
pub fn matches(event: &Event, browsers: &BTreeSet<LegacyBrowser>) -> bool { | ||
if let Some(user_agent_string) = event.user_agent() { | ||
let user_agent = relay_ua::parse_user_agent(user_agent_string); | ||
fn matches(user_agent: &str, browsers: &BTreeSet<LegacyBrowser>) -> 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.
I made the matches
functions private everywhere, they do not need to be public.
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.
nit: we should align all matches
implementations for consistency -- sometimes they take item
(convenience) and some others just the value to filter on.
Co-authored-by: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com>
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.
Perfect. This will be easy to implement for replays.
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.
nit: we should align all matches implementations for consistency
@iker-barriocanal They are all private functions, so IMO they should do what makes the most sense in local context. I pass the value directly where the function needs only that value, and the full item in cases where the function needs more than one value. Let me know if that makes sense.
Currently, inbound filters only work for event types, that is error events and transactions. In the near future we will want inbound filters to apply to other data types as well, such as standalone spans and session replays. To prepare for this generalization, make filters act on a trait that supplies the necessary field instead of the
Event
itself:ref: #3317
#skip-changelog