diff --git a/src/sentry/search/eap/columns.py b/src/sentry/search/eap/columns.py index 4d2a7fc045814..9c4a779a1f458 100644 --- a/src/sentry/search/eap/columns.py +++ b/src/sentry/search/eap/columns.py @@ -255,6 +255,11 @@ def simple_measurements_field(field) -> ResolvedColumn: internal_name="sentry.segment_name", search_type="string", ), + ResolvedColumn( + public_alias="transaction.span_id", + internal_name="sentry.segment_id", + search_type="string", + ), ResolvedColumn( public_alias="replay.id", internal_name="sentry.replay_id", 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 ae2fa86b8edd6..370eb6b444432 100644 --- a/tests/snuba/api/endpoints/test_organization_events_span_indexed.py +++ b/tests/snuba/api/endpoints/test_organization_events_span_indexed.py @@ -1,4 +1,5 @@ import uuid +from datetime import datetime from unittest import mock import pytest @@ -754,7 +755,6 @@ def test_orderby_alias(self): "dataset": self.dataset, } ) - assert response.status_code == 200, response.content data = response.data["data"] meta = response.data["meta"] @@ -771,6 +771,58 @@ def test_orderby_alias(self): ] assert meta["dataset"] == self.dataset + @pytest.mark.querybuilder + def test_explore_sample_query(self): + spans = [ + self.create_span( + {"description": "foo", "sentry_tags": {"status": "success"}}, + start_ts=self.ten_mins_ago, + ), + self.create_span( + {"description": "bar", "sentry_tags": {"status": "invalid_argument"}}, + start_ts=self.nine_mins_ago, + ), + ] + self.store_spans( + spans, + is_eap=self.is_eap, + ) + response = self.do_request( + { + "field": [ + "id", + "project", + "span.op", + "span.description", + "span.duration", + "timestamp", + "trace", + "transaction.span_id", + ], + # This is to skip INP spans + "query": "!transaction.span_id:00", + "orderby": "timestamp", + "statsPeriod": "1h", + "project": self.project.id, + "dataset": self.dataset, + } + ) + assert response.status_code == 200, response.content + data = response.data["data"] + meta = response.data["meta"] + assert len(data) == 2 + for source, result in zip(spans, data): + assert result["id"] == source["span_id"], "id" + assert result["span.duration"] == 1000.0, "duration" + assert result["span.op"] == "", "op" + assert result["span.description"] == source["description"], "description" + assert datetime.fromisoformat(result["timestamp"]).timestamp() == pytest.approx( + source["end_timestamp_precise"], abs=5 + ), "timestamp" + assert result["transaction.span_id"] == source["segment_id"], "transaction.span_id" + assert result["project"] == result["project.name"] == self.project.slug, "project" + assert meta["dataset"] == self.dataset + def test_span_status(self): self.store_spans( [