Skip to content

Commit

Permalink
fix(eap): Add test for explore homepage (#81206)
Browse files Browse the repository at this point in the history
- Adds a test that matches the explore's homepage query
  • Loading branch information
wmak authored Nov 22, 2024
1 parent 51ec8d0 commit 42881a6
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/sentry/search/eap/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid
from datetime import datetime
from unittest import mock

import pytest
Expand Down Expand Up @@ -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"]
Expand All @@ -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(
[
Expand Down

0 comments on commit 42881a6

Please sign in to comment.