-
Notifications
You must be signed in to change notification settings - Fork 93
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(rules): Move rules DSL to relay-protocol #2608
Conversation
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.
LGTM! @jan-auer there might be a better place to put the rule-matching logic, but I think putting it in relay-protocol
is an improvement over importing relay-samping
everywhere.
relay-cabi/src/processing.rs
Outdated
use relay_protocol::RuleCondition; | ||
use relay_protocol::{Annotated, Remark}; |
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.
Let's merge these imports.
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.
Please excuse the late review. See the comments below for a follow-up PR.
Eventually, we can look for an even better place for these types; relay-protocol
is not the intended crate for this, as it is meant to contain foundational types for building our data schemas, which rule conditions are not part of. That said, I also haven't found the right place yet.
mod value; | ||
|
||
pub use self::annotated::*; | ||
pub use self::condition::*; |
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 module contains a lot of types that usually do not need to be imported. By glob-exporting them, we're littering the global crate namespace as can be seen in the docs now.
When you compare the imports with how relay-sampling
was structured, there was an explicit re-export of the RuleCondition
type, as this is the most commonly used one, but all the other types were left in a pub mod condition
instead. I'd prefer if we do this here, too.
That is independent of whether other modules are glob-exported or not.
pub use self::impls::*; | ||
pub use self::macros::*; | ||
pub use self::meta::*; | ||
pub use self::size::*; | ||
pub use self::traits::*; | ||
pub use self::utils::*; |
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.
Definitely do not glob-export internal utils to a public namespace. This file contains the function is_default
, which shouldn't be part of the public API of relay-protocol
. Instead, we should remove that module and just declare the function locally where needed.
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 thought about this, you are right that it's not good. Definitely needs to be re-worked.
use crate::config::{ | ||
DecayingFunction, RuleId, RuleType, SamplingRule, SamplingValue, TimeRange, | ||
}; | ||
use crate::dsc::TraceUserContext; | ||
use crate::evaluation::MatchedRuleIds; | ||
use crate::DynamicSamplingContext; | ||
use relay_protocol::RuleCondition; |
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.
Please move this import into the import group above.
Follow up to #2608: * Remove `utils` crate from `relay-protocol`. * Only export `RuleCondition` from the `condition` module`. I was not able to remove the `relay-sampling` dependency anywhere yet, because `relay-cabi` and `relay-dynamic-config` import `SamplingConfig`. But we will be able to change the dependency in #2595.
This PR moves the
condition
module fromrelay-sampling
torelay-protocol
. In order to perform the refactor, an adaptation of tests had to be done, in which dependencies fromrelay-sampling
where removed by adding mock structs that implementGetter
.