-
-
Notifications
You must be signed in to change notification settings - Fork 61
feat(eap): Add support for any aggregation function in EAP RPC #7660
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0fcdd58 to
b4acbf1
Compare
volokluev
reviewed
Jan 22, 2026
Member
volokluev
left a comment
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.
looks good, please add a test for TraceItemTable also
Comment on lines
+310
to
+338
| def test_any(self) -> None: | ||
| # store a test metric with a value of 1, every second of one hour | ||
| granularity_secs = 300 | ||
| query_duration = 60 * 30 | ||
| store_spans_timeseries( | ||
| BASE_TIME, | ||
| 1, | ||
| 3600, | ||
| metrics=[DummyMetric("test_metric", get_value=lambda x: 1)], | ||
| ) | ||
|
|
||
| message = TimeSeriesRequest( | ||
| meta=RequestMeta( | ||
| project_ids=[1, 2, 3], | ||
| organization_id=1, | ||
| cogs_category="something", | ||
| referrer="something", | ||
| start_timestamp=Timestamp(seconds=int(BASE_TIME.timestamp())), | ||
| end_timestamp=Timestamp(seconds=int(BASE_TIME.timestamp() + query_duration)), | ||
| trace_item_type=TraceItemType.TRACE_ITEM_TYPE_SPAN, | ||
| ), | ||
| aggregations=[ | ||
| AttributeAggregation( | ||
| aggregate=Function.FUNCTION_ANY, | ||
| key=AttributeKey(type=AttributeKey.TYPE_FLOAT, name="test_metric"), | ||
| label="any", | ||
| extrapolation_mode=ExtrapolationMode.EXTRAPOLATION_MODE_NONE, | ||
| ), | ||
| ], |
Member
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 test is basically the same thing as the test below only one is necessary
Add FUNCTION_ANY to the EAP RPC aggregation functions, enabling queries to return any non-null value from a group. This is useful for retrieving representative values when the specific value doesn't matter. Changes: - Add anyIfOrNull to both extrapolated and non-extrapolated function maps - Skip round() for FUNCTION_ANY to support non-numeric returns - Add proper type-based converters for FUNCTION_ANY in trace item table - Add tests for time series, extrapolation, and string attribute scenarios Co-Authored-By: Claude Opus 4.5 <[email protected]>
b4acbf1 to
85b17b3
Compare
volokluev
approved these changes
Jan 22, 2026
Extract converter creation logic into helper functions: - _get_converter_for_type(): Returns converter based on AttributeKey type - _get_double_converter(): Returns converter for numeric aggregations This reduces code duplication and improves maintainability. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
FUNCTION_ANYto the EAP RPC aggregation functionsany()resultsDetails
The
any()aggregation function returns any non-null value from a group. This is useful for retrieving representative values when the specific value doesn't matter.Implementation:
anyIfOrNulltoaggregation_to_expression()for non-extrapolated queriesanyIfOrNulltoget_extrapolated_function()for extrapolated queriesround()wrapper forFUNCTION_ANYsince it can return non-numeric typesFUNCTION_ANYin trace item table to properly handle string/int/boolean resultsNote: This requires
sentry-protos>=0.4.14which includesFUNCTION_ANY(value 13).Test plan
test_anyfor basic time series aggregation without extrapolationtest_any_extrapolatedfor time series aggregation with sample-weighted extrapolationtest_any_aggregation_with_string_attribute- inserts many spans with the same string attribute value (custom_tag="blah") and verifiesany()returns the string correctly in trace item table🤖 Generated with Claude Code