diff --git a/src/sentry/search/eap/ourlogs/aggregates.py b/src/sentry/search/eap/ourlogs/aggregates.py index 0c26bd941891..2e349361eae7 100644 --- a/src/sentry/search/eap/ourlogs/aggregates.py +++ b/src/sentry/search/eap/ourlogs/aggregates.py @@ -75,6 +75,25 @@ class NumericDefinition(AggregateDefinition): "min": NumericDefinition( internal_function=Function.FUNCTION_MIN, ), + "any": AggregateDefinition( + internal_function=Function.FUNCTION_ANY, + default_search_type="duration", + arguments=[ + AttributeArgumentDefinition( + attribute_types={ + "string", + "duration", + "number", + "integer", + "percentage", + "currency", + *constants.SIZE_TYPE, + *constants.DURATION_TYPE, + }, + default_arg="trace", + ) + ], + ), } diff --git a/tests/snuba/api/endpoints/test_organization_events_ourlogs.py b/tests/snuba/api/endpoints/test_organization_events_ourlogs.py index 013c37ac6605..e49610c4eb01 100644 --- a/tests/snuba/api/endpoints/test_organization_events_ourlogs.py +++ b/tests/snuba/api/endpoints/test_organization_events_ourlogs.py @@ -1,3 +1,4 @@ +import math from datetime import datetime, timedelta, timezone from unittest.mock import ANY, patch from uuid import uuid4 @@ -1232,6 +1233,29 @@ def test_p50_if_message(self): assert response.status_code == 200 assert response.data["data"] == [{"p50_if(`message:log`,payload_size)": 1234567}] + def test_any_function(self): + log = self.create_ourlog( + {"body": "log"}, + attributes={"sentry.payload_size_bytes": 1234567}, + timestamp=self.ten_mins_ago, + ) + self.store_eap_items([log]) + request = { + "field": ["any(trace)", "any(timestamp)"], + "project": self.project.id, + "dataset": self.dataset, + "statsPeriod": "1h", + } + + response = self.do_request(request) + assert response.status_code == 200, response.content + assert response.data["data"] == [ + { + "any(trace)": log.trace_id, + "any(timestamp)": math.floor(self.ten_mins_ago.timestamp()), + } + ] + def test_aggregate_condition_filters_grouped_logs(self) -> None: self.store_eap_items( [