-
-
Notifications
You must be signed in to change notification settings - Fork 62
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(eap-api): support conditional aggregations in SELECT #6870
Conversation
3224936
to
4217164
Compare
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
4217164
to
d061eee
Compare
tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py
Show resolved
Hide resolved
tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py
Show resolved
Hide resolved
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 you also need to update the confidence interval calculations to include the condition. Also, could you please add a test for extrapolated conditional aggregates
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 you should clean up those print statements laying around but other than that LGTM assuming the tests pass. Also thanks for including a PR description.
tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py
Show resolved
Hide resolved
tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py
Outdated
Show resolved
Hide resolved
tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py
Show resolved
Hide resolved
tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py
Outdated
Show resolved
Hide resolved
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.
From the changes that I see in sentry-protos, you have recreated the aggregation struct with the condition field that you need (we spoke about this):
But in this code here, what you are doing is creating branches for both cases, this makes the code more fragmented.
What you should be doing instead, is converting the old (soon to be deprecated) object into the new AttributeConditionalAggregation
object in the very beginning and then doing all of your operations from there
d9ff324
to
4c5dcc2
Compare
There's still some of the fragmented code in |
68376ab
to
cea3456
Compare
c8d8a92
to
dca9e59
Compare
6d90d21
to
ac24c55
Compare
e8c2938
to
24b3a30
Compare
9a59a3a
to
462a2a7
Compare
tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py
Outdated
Show resolved
Hide resolved
tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table_extrapolation.py
Outdated
Show resolved
Hide resolved
tests/web/rpc/v1/visitors/test_sparse_aggregate_attribute_transformer.py
Outdated
Show resolved
Hide resolved
), | ||
alias=alias, | ||
) | ||
|
||
|
||
def _get_count_column_alias(aggregation: AttributeAggregation) -> str: | ||
def _get_count_column_alias( | ||
aggregation: AttributeAggregation | AttributeConditionalAggregation, |
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 you've transformed everything up front, when would you still have an AttributeAggregation
in the arguments 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.
time series endpoint calls get_count_column which calls _get_count_column_alias. We haven't transformed it in time series endpoint yet (will do in later PR)
@@ -80,6 +87,48 @@ def _transform_request(request: TraceItemTableRequest) -> TraceItemTableRequest: | |||
return SparseAggregateAttributeTransformer(request).transform() | |||
|
|||
|
|||
def convert_to_conditional_aggregation(in_msg: TraceItemTableRequest) -> None: |
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.
How different would this function be for the TimeSeries endpoint?
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.
- leave a comment explaining why this is being done. It's not immediately clear unless you are the user
- Test this function independently. It has clearly defined inputs and outputs
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.
Overall looks good! My main concern is just testing that request processor you wrote independently
cc9ee4f
to
f70521a
Compare
c3d740d
to
ce2571e
Compare
tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py
Show resolved
Hide resolved
@@ -2595,12 +2785,73 @@ def test_nonexistent_attribute(setup_teardown: Any) -> None: | |||
] | |||
|
|||
|
|||
def _build_sum_attribute_aggregation_column_with_name(name: str) -> Column: |
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.
by which i mean this should be in its own file
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.
test_conditional_aggregation.py
This function adds the equivalent conditional aggregation for every aggregation in each Column or AggregationFilter. We don't add the filter field so outside code logic will set the default condition to true. The purpose of this function is to "transform" every AttributeAggregation to AttributeConditionalAggregation in order to avoid code fragmentation | ||
""" | ||
|
||
def _add_conditional_aggregation( |
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.
see if you can replace in all the cases so you don't have the split behavior with Column and AggregationComparsionFilter
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.
replace is done with input.ClearField("aggregation")
, but I still need the separate isinstance(input, Column)
and isinstance(input, AggregationFilter)
because of mypy. Also I feel like it makes _convert
more readable(?)
@@ -80,6 +87,52 @@ def _transform_request(request: TraceItemTableRequest) -> TraceItemTableRequest: | |||
return SparseAggregateAttributeTransformer(request).transform() | |||
|
|||
|
|||
def convert_to_conditional_aggregation(in_msg: TraceItemTableRequest) -> None: | |||
""" | |||
This function adds the equivalent conditional aggregation for every aggregation in each Column or AggregationFilter. We don't add the filter field so outside code logic will set the default condition to true. The purpose of this function is to "transform" every AttributeAggregation to AttributeConditionalAggregation in order to avoid code fragmentation |
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.
Explain historical reasons here, that's the important part. Think of yourself as a person new to this code
2c9aeeb
to
3e6a855
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.
much better
https://github.com/getsentry/eap-planning/issues/166
We now support conditional aggregations for EndpointTraceItemTable. Next is time series