|
3 | 3 | from collections.abc import Callable, Iterable, Mapping, Sequence
|
4 | 4 | from concurrent.futures import ThreadPoolExecutor, as_completed
|
5 | 5 | from datetime import datetime, timedelta
|
6 |
| -from typing import Any, Deque, Optional, TypedDict, TypeVar, cast |
| 6 | +from typing import Any, Deque, Optional, TypedDict, TypeVar |
7 | 7 |
|
8 | 8 | import sentry_sdk
|
9 | 9 | from django.http import Http404, HttpRequest, HttpResponse
|
|
44 | 44 | "SnubaTransaction",
|
45 | 45 | {
|
46 | 46 | "id": str,
|
| 47 | + "issue_occurrences": Sequence[IssueOccurrence], |
47 | 48 | "transaction.status": int,
|
48 | 49 | "transaction.op": str,
|
49 | 50 | "transaction.duration": int,
|
50 | 51 | "transaction": str,
|
51 | 52 | "timestamp": str,
|
| 53 | + "occurrence_spans": Sequence[dict[str, object]], |
52 | 54 | "precise.start_ts": int,
|
53 | 55 | "precise.finish_ts": int,
|
54 | 56 | "trace.span": str,
|
@@ -187,7 +189,7 @@ def nodestore_event(self) -> Event | None:
|
187 | 189 | )
|
188 | 190 | return self._nodestore_event
|
189 | 191 |
|
190 |
| - def load_performance_issues(self, light: bool, snuba_params: ParamsType) -> None: |
| 192 | + def load_performance_issues(self, light: bool, snuba_params: ParamsType | None) -> None: |
191 | 193 | """Doesn't get suspect spans, since we don't need that for the light view"""
|
192 | 194 | for group_id in self.event["issue.ids"]:
|
193 | 195 | group = Group.objects.filter(id=group_id, project=self.event["project.id"]).first()
|
@@ -322,7 +324,7 @@ def full_dict(
|
322 | 324 | return
|
323 | 325 | else:
|
324 | 326 | visited.add(self.event["id"])
|
325 |
| - result = cast(FullResponse, self.to_dict()) |
| 327 | + result = self.to_dict() |
326 | 328 | if detailed and "transaction.status" in self.event:
|
327 | 329 | result.update(
|
328 | 330 | {
|
@@ -423,7 +425,7 @@ def count_performance_issues(trace_id: str, params: Mapping[str, str]) -> int:
|
423 | 425 | )
|
424 | 426 | transaction_query.columns.append(Function("count()", alias="total_groups"))
|
425 | 427 | count = transaction_query.run_query("api.trace-view.count-performance-issues")
|
426 |
| - return cast(int, count["data"][0].get("total_groups", 0)) |
| 428 | + return count["data"][0].get("total_groups", 0) |
427 | 429 |
|
428 | 430 |
|
429 | 431 | @sentry_sdk.tracing.trace
|
@@ -593,9 +595,7 @@ def query_trace_data(
|
593 | 595 | for key, value in zip(result["measurements.key"], result["measurements.value"])
|
594 | 596 | }
|
595 | 597 |
|
596 |
| - return cast(Sequence[SnubaTransaction], transformed_results[0]), cast( |
597 |
| - Sequence[SnubaError], transformed_results[1] |
598 |
| - ) |
| 598 | + return transformed_results[0], transformed_results[1] |
599 | 599 |
|
600 | 600 |
|
601 | 601 | def build_span_query(trace_id, spans_params, query_spans):
|
@@ -886,16 +886,16 @@ def get(self, request: HttpRequest, organization: Organization, trace_id: str) -
|
886 | 886 | return Response(status=404)
|
887 | 887 |
|
888 | 888 | # Detailed is deprecated now that we want to use spans instead
|
889 |
| - detailed: bool = request.GET.get("detailed", "0") == "1" |
| 889 | + detailed = request.GET.get("detailed", "0") == "1" |
890 | 890 | # Temporary url params until we finish migrating the frontend
|
891 |
| - use_spans: bool = request.GET.get("useSpans", "0") == "1" |
| 891 | + use_spans = request.GET.get("useSpans", "0") == "1" |
892 | 892 | update_snuba_params_with_timestamp(request, params)
|
893 | 893 |
|
894 | 894 | sentry_sdk.set_tag("trace_view.using_spans", str(use_spans))
|
895 | 895 | if detailed and use_spans:
|
896 | 896 | raise ParseError("Cannot return a detailed response while using spans")
|
897 |
| - limit: int = min(int(request.GET.get("limit", MAX_TRACE_SIZE)), 10_000) |
898 |
| - event_id: str | None = request.GET.get("event_id") or request.GET.get("eventId") |
| 897 | + limit = min(int(request.GET.get("limit", MAX_TRACE_SIZE)), 10_000) |
| 898 | + event_id = request.GET.get("event_id") or request.GET.get("eventId") |
899 | 899 |
|
900 | 900 | # Only need to validate event_id as trace_id is validated in the URL
|
901 | 901 | if event_id and not is_event_id(event_id):
|
@@ -1318,9 +1318,11 @@ def serialize(
|
1318 | 1318 | parent_events[child_event["id"]] = TraceEvent(
|
1319 | 1319 | child_event,
|
1320 | 1320 | current_event["id"],
|
1321 |
| - previous_event.generation + 1 |
1322 |
| - if previous_event.generation is not None |
1323 |
| - else None, |
| 1321 | + ( |
| 1322 | + previous_event.generation + 1 |
| 1323 | + if previous_event.generation is not None |
| 1324 | + else None |
| 1325 | + ), |
1324 | 1326 | snuba_params=params,
|
1325 | 1327 | )
|
1326 | 1328 | # Add this event to its parent's children
|
|
0 commit comments