From 39d646934a768a44d62858e5ae53fb8dbc686cfc Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Fri, 11 Oct 2024 17:42:14 -0400 Subject: [PATCH 1/2] fix(eap): Count takes arg Unlike before, count() will now take an argument to count the numeric attribute with a default to count span.duration. --- src/sentry/search/eap/columns.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/sentry/search/eap/columns.py b/src/sentry/search/eap/columns.py index ae952059bff7cc..1a690a4b1a1011 100644 --- a/src/sentry/search/eap/columns.py +++ b/src/sentry/search/eap/columns.py @@ -222,12 +222,7 @@ def context_constructor(params: SnubaParams) -> VirtualColumnContext: "sum": FunctionDefinition( internal_function=Function.FUNCTION_SUM, search_type="duration", - arguments=[ - ArgumentDefinition( - argument_type="duration", - default_arg="span.duration", - ) - ], + arguments=[ArgumentDefinition(argument_type="duration", default_arg="span.duration")], ), "avg": FunctionDefinition( internal_function=Function.FUNCTION_AVERAGE, @@ -237,7 +232,7 @@ def context_constructor(params: SnubaParams) -> VirtualColumnContext: "count": FunctionDefinition( internal_function=Function.FUNCTION_COUNT, search_type="number", - arguments=[ArgumentDefinition(ignored=True)], + arguments=[ArgumentDefinition(argument_type="duration", default_arg="span.duration")], ), "p50": FunctionDefinition( internal_function=Function.FUNCTION_P50, From 63a2e819481b7e747c1e0ac121d5b69920304b68 Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Fri, 11 Oct 2024 19:37:56 -0400 Subject: [PATCH 2/2] fix tests --- tests/sentry/search/eap/test_spans.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/sentry/search/eap/test_spans.py b/tests/sentry/search/eap/test_spans.py index d8a81005b456ea..865f68143afefa 100644 --- a/tests/sentry/search/eap/test_spans.py +++ b/tests/sentry/search/eap/test_spans.py @@ -318,12 +318,16 @@ def test_function_alias(self): def test_count(self): resolved_column, virtual_context = self.resolver.resolve_column("count()") assert resolved_column.proto_definition == AttributeAggregation( - aggregate=Function.FUNCTION_COUNT, key=None, label="count()" + aggregate=Function.FUNCTION_COUNT, + key=AttributeKey(name="duration_ms", type=AttributeKey.Type.TYPE_INT), + label="count()", ) assert virtual_context is None resolved_column, virtual_context = self.resolver.resolve_column("count(span.duration)") assert resolved_column.proto_definition == AttributeAggregation( - aggregate=Function.FUNCTION_COUNT, key=None, label="count(span.duration)" + aggregate=Function.FUNCTION_COUNT, + key=AttributeKey(name="duration_ms", type=AttributeKey.Type.TYPE_INT), + label="count(span.duration)", ) assert virtual_context is None