From e3dbd726b4b5de18f1b03ce42c7d5ea048a44fc2 Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Tue, 18 Nov 2025 11:44:40 -0500 Subject: [PATCH] feat(spans): Allow integers in count if conditions Integers were left out for no apparent reason. --- src/sentry/search/eap/spans/aggregates.py | 1 + .../test_organization_events_span_indexed.py | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/sentry/search/eap/spans/aggregates.py b/src/sentry/search/eap/spans/aggregates.py index 45fdd738b1dfbd..59de1ff0ebe6f7 100644 --- a/src/sentry/search/eap/spans/aggregates.py +++ b/src/sentry/search/eap/spans/aggregates.py @@ -210,6 +210,7 @@ def resolve_bounded_sample(args: ResolvedArguments) -> tuple[AttributeKey, Trace "string", "duration", "number", + "integer", "percentage", "currency", "boolean", diff --git a/tests/snuba/api/endpoints/test_organization_events_span_indexed.py b/tests/snuba/api/endpoints/test_organization_events_span_indexed.py index 3475ba4f136e05..ea79830e522c9f 100644 --- a/tests/snuba/api/endpoints/test_organization_events_span_indexed.py +++ b/tests/snuba/api/endpoints/test_organization_events_span_indexed.py @@ -6247,6 +6247,51 @@ def test_count_if_numeric_raises_invalid_search_query_with_bad_value(self) -> No assert response.status_code == 400, response.content assert "Invalid Parameter " in response.data["detail"].title() + def test_count_if_integer(self) -> None: + self.store_spans( + [ + self.create_span( + {"description": "foo"}, + measurements={"gen_ai.usage.total_tokens": {"value": 100}}, + start_ts=self.ten_mins_ago, + duration=400, + ), + self.create_span( + {"description": "bar"}, + measurements={"gen_ai.usage.total_tokens": {"value": 200}}, + start_ts=self.ten_mins_ago, + duration=400, + ), + self.create_span( + {"description": "baz"}, + measurements={"gen_ai.usage.total_tokens": {"value": 300}}, + start_ts=self.ten_mins_ago, + duration=200, + ), + ], + is_eap=True, + ) + response = self.do_request( + { + "field": ["count_if(gen_ai.usage.total_tokens,greater,200)"], + "query": "", + "orderby": "count_if(gen_ai.usage.total_tokens,greater,200)", + "project": self.project.id, + "dataset": "spans", + } + ) + + assert response.status_code == 200, response.content + data = response.data["data"] + meta = response.data["meta"] + assert len(data) == 1 + assert data == [ + { + "count_if(gen_ai.usage.total_tokens,greater,200)": 1, + }, + ] + assert meta["dataset"] == "spans" + def test_apdex_function(self) -> None: """Test the apdex function with span.duration and threshold.""" # Create spans with different durations to test apdex calculation