Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sentry/search/events/datasets/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class DiscoverDatasetConfig(DatasetConfig):
"user_misery()",
}
non_nullable_keys = {"event.type"}
nullable_context_keys = {"thread.id"}
nullable_context_keys = {"thread.id", "trace", "trace.span"}
use_entity_prefix_for_fields: bool = False

def __init__(self, builder: BaseQueryBuilder):
Expand Down
54 changes: 54 additions & 0 deletions tests/snuba/api/endpoints/test_organization_events_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,60 @@ def test_errors_dataset(self) -> None:
assert response.status_code == 200, response.content
assert [attrs for time, attrs in response.data["data"]] == [[{"count": 1}], [{"count": 2}]]

def test_errors_dataset_has_trace(self) -> None:
"""The has:trace filters limit error stats to events containing the requested ID."""
traced_event = self.store_event(
data={
"event_id": uuid4().hex,
"message": "event with a trace",
"timestamp": (self.day_ago + timedelta(minutes=2)).isoformat(),
"fingerprint": ["has-trace-group"],
"tags": {"sentry:user": self.user.email},
"contexts": {
"trace": {
"trace_id": uuid4().hex,
"span_id": uuid4().hex[:16],
}
},
},
project_id=self.project.id,
)
untraced_event = self.store_event(
data={
"event_id": uuid4().hex,
"message": "event without a trace",
"timestamp": (self.day_ago + timedelta(hours=1, minutes=2)).isoformat(),
"fingerprint": ["has-trace-group"],
"tags": {"sentry:user": self.user2.email},
},
project_id=self.project.id,
)
assert untraced_event.group_id == traced_event.group_id

for trace_field in ["trace", "trace.span"]:
response = self.do_request(
{
"start": self.day_ago,
"end": self.day_ago + timedelta(hours=2),
"interval": "1h",
"dataset": "errors",
"project": self.project.id,
"query": f"issue:{traced_event.group.qualified_short_id} has:{trace_field}",
"yAxis": ["count()", "count_unique(user)"],
"partial": "1",
},
)

assert response.status_code == 200, response.content
assert [attrs for _time, attrs in response.data["count()"]["data"]] == [
[{"count": 1}],
[{"count": 0}],
]
assert [attrs for _time, attrs in response.data["count_unique(user)"]["data"]] == [
[{"count": 1}],
[{"count": 0}],
]

def test_errors_dataset_with_environment(self) -> None:
environment = self.create_environment(project=self.project)
self.store_event(
Expand Down
Loading