Skip to content

Commit e44845e

Browse files
Zylphrexcmanallen
authored andcommitted
fix(eap): Count takes arg (#79066)
Unlike before, count() will now take an argument to count the numeric attribute with a default to count `span.duration`.
1 parent d1c7623 commit e44845e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Diff for: src/sentry/search/eap/columns.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,7 @@ def context_constructor(params: SnubaParams) -> VirtualColumnContext:
222222
"sum": FunctionDefinition(
223223
internal_function=Function.FUNCTION_SUM,
224224
search_type="duration",
225-
arguments=[
226-
ArgumentDefinition(
227-
argument_type="duration",
228-
default_arg="span.duration",
229-
)
230-
],
225+
arguments=[ArgumentDefinition(argument_type="duration", default_arg="span.duration")],
231226
),
232227
"avg": FunctionDefinition(
233228
internal_function=Function.FUNCTION_AVERAGE,
@@ -237,7 +232,7 @@ def context_constructor(params: SnubaParams) -> VirtualColumnContext:
237232
"count": FunctionDefinition(
238233
internal_function=Function.FUNCTION_COUNT,
239234
search_type="number",
240-
arguments=[ArgumentDefinition(ignored=True)],
235+
arguments=[ArgumentDefinition(argument_type="duration", default_arg="span.duration")],
241236
),
242237
"p50": FunctionDefinition(
243238
internal_function=Function.FUNCTION_P50,

Diff for: tests/sentry/search/eap/test_spans.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,16 @@ def test_function_alias(self):
318318
def test_count(self):
319319
resolved_column, virtual_context = self.resolver.resolve_column("count()")
320320
assert resolved_column.proto_definition == AttributeAggregation(
321-
aggregate=Function.FUNCTION_COUNT, key=None, label="count()"
321+
aggregate=Function.FUNCTION_COUNT,
322+
key=AttributeKey(name="duration_ms", type=AttributeKey.Type.TYPE_INT),
323+
label="count()",
322324
)
323325
assert virtual_context is None
324326
resolved_column, virtual_context = self.resolver.resolve_column("count(span.duration)")
325327
assert resolved_column.proto_definition == AttributeAggregation(
326-
aggregate=Function.FUNCTION_COUNT, key=None, label="count(span.duration)"
328+
aggregate=Function.FUNCTION_COUNT,
329+
key=AttributeKey(name="duration_ms", type=AttributeKey.Type.TYPE_INT),
330+
label="count(span.duration)",
327331
)
328332
assert virtual_context is None
329333

0 commit comments

Comments
 (0)