-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(processing): Separate second query of percentage comparison #73099
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #73099 +/- ##
==========================================
- Coverage 78.01% 78.00% -0.01%
==========================================
Files 6630 6632 +2
Lines 295916 296082 +166
Branches 50971 50989 +18
==========================================
+ Hits 230848 230967 +119
- Misses 58732 58778 +46
- Partials 6336 6337 +1
|
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 makes sense to me, I'll give it a second review once you've finished tests
if len(query_values) == 2: | ||
calculated_value = percent_increase(calculated_value, query_values[1]) | ||
|
||
target_value = float(condition_data["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.
Previously we converted this to a string then float, not sure if that's important though
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.
@ceorourke do you remember why we originally did that here?
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 think it was just to match this https://github.com/getsentry/sentry/blob/master/src/sentry/rules/conditions/event_frequency.py - what's the data type initially? A float?
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 a string but I think we can just convert that directly, like here
e96bf12
to
accf24d
Compare
c62a186
to
edbfdf9
Compare
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.
some pre-lim comments
haven't looked over the tests yet, lookin gnow
""" | ||
end = timezone.now() - interval | ||
if comparison_interval: | ||
end = end - comparison_interval |
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're already passing in the end
- why do we pass in the offset?
Can we just calculate the new end
when invoking this helper?
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 but I liked having this function handle all the time calculations instead of doing it in get_rate_bulk
and get_rate
with self.disable_consistent_snuba_mode(duration): | ||
result = self.query(event, start, end, environment_id=environment_id) | ||
if comparison_type == ComparisonType.PERCENT: | ||
# TODO: Figure out if there's a way we can do this less frequently. All queries are | ||
# automatically cached for 10s. We could consider trying to cache this and the main | ||
# query for 20s to reduce the load. | ||
start, end = self.get_comparison_start_end(comparison_interval, duration) | ||
start, end = self.get_comparison_start_end( |
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.
RE: comments above
1 - lets make this kwargs
2 - lets pre-calucate the end
here
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.
some more comments on the tests
query, but the second percent query is separate. | ||
""" | ||
|
||
def ordered_callthrough(descending=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.
🤔 can we call this mock_get_condition_group
? or toss side_effect
/callback
somewhere in teh name of this?
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.
Also - does this need to be a separate helper?
Why are we modifying the args being passed into this method? This means we aren't properly capturing how the implementation would behave.
This feels smelly 🤔
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're modifying the order of the list of rules being passed into the function. We need to do this to test the behavior when count and percent conditions can share a query, so that ordering doesn't matter.
Originally they come in a random order, so we test for both orderings (count first then percent and vice versa)
4a5c976
to
edbfdf9
Compare
c42b4d8
to
b4fc09e
Compare
Fixes ALRT-101