ref(rules): Add batch_query_hook to EventFrequencyCondition#68559
Conversation
Bundle ReportChanges will increase total bundle size by 93.75kB ⬆️
|
saponifi3d
left a comment
There was a problem hiding this comment.
i think the biggest thing here is to make sure we can't do the queries in a single scan, since that has such a big impact on our goals for the project.
| start=start, | ||
| end=end, | ||
| environment_id=environment_id, | ||
| referrer_suffix="alert_event_frequency", |
There was a problem hiding this comment.
| referrer_suffix="alert_event_frequency", | |
| referrer_suffix=referrer_suffix |
| generic_issues = [group for group in groups if group.issue_category != GroupCategory.ERROR] | ||
|
|
||
| if error_issues: | ||
| error_sums = self.get_chunked_sums( |
There was a problem hiding this comment.
In javascript i'd generally define get_chunked_sums inside of the batch_query_hook function and then reference the start, end, and environment_id from the outer scope. Is that a faux pas in python? (if not, it might help DRY this code up a little more and reduce it by 9 more lines 😎)
It'd be something like:
def get_chunked_sums(groups: list[Group], referrer_suffix: str):
# same code you have for get_chunked_sums
if error_issues:
error_sums = get_chunked_sums(
groups=error_issues,
# looks like referrer_suffix could be DRY'd up and hardcoded in get_chunked_sums as well
referrer_suffix="alert_event_frequency"
)| class EventFrequencyQueryTest(SnubaTestCase, RuleTestCase, PerformanceIssueTestCase): | ||
| rule_cls = EventFrequencyCondition | ||
|
|
||
| def test_batch_query(self): |
saponifi3d
left a comment
There was a problem hiding this comment.
lgtm once we either dry the code up or update the param 🎉
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
…#68672) Follow up to #68559 and a part 2 of getsentry/team-core-product-foundations#239 to add a `batch_query_hook` function for the `EventUniqueUserFrequencyCondition`.
Add a `batch_query_hook` to the `EventFrequencyCondition` so that when we process "slow" rule conditions we can batch the queries by group ids. Partially closes https://github.com/getsentry/team-core-product-foundations/issues/239
…#68672) Follow up to #68559 and a part 2 of https://github.com/getsentry/team-core-product-foundations/issues/239 to add a `batch_query_hook` function for the `EventUniqueUserFrequencyCondition`.
Add a
batch_query_hookto theEventFrequencyConditionso that when we process "slow" rule conditions we can batch the queries by group ids.Partially closes https://github.com/getsentry/team-core-product-foundations/issues/239