|
1 | 1 | import hashlib
|
2 | 2 | from collections import defaultdict, namedtuple
|
3 | 3 | from collections.abc import Mapping
|
4 |
| -from datetime import datetime, timezone |
| 4 | +from datetime import datetime |
5 | 5 | from typing import Any, Optional, TypedDict
|
6 | 6 |
|
7 | 7 | import sentry_sdk
|
|
22 | 22 | from sentry.utils.snuba import raw_snql_query
|
23 | 23 |
|
24 | 24 | ALLOWED_BACKENDS = ["indexedSpans", "nodestore"]
|
25 |
| -CUTOVER_DATE = datetime(2024, 3, 22, tzinfo=timezone.utc) |
26 | 25 |
|
27 | 26 | EventSpan = namedtuple(
|
28 | 27 | "EventSpan",
|
@@ -337,29 +336,31 @@ class OrganizationSpansAggregationEndpoint(OrganizationEventsEndpointBase):
|
337 | 336 | }
|
338 | 337 |
|
339 | 338 | def get(self, request: Request, organization: Organization) -> Response:
|
340 |
| - if not features.has("organizations:spans-first-ui", organization, actor=request.user): |
| 339 | + if not features.has( |
| 340 | + "organizations:starfish-aggregate-span-waterfall", organization, actor=request.user |
| 341 | + ): |
341 | 342 | return Response(status=404)
|
342 | 343 |
|
343 | 344 | try:
|
344 | 345 | params = self.get_snuba_params(request, organization)
|
345 | 346 | except NoProjects:
|
346 | 347 | return Response(status=404)
|
347 | 348 |
|
348 |
| - start = params["start"] |
349 |
| - if start and start < CUTOVER_DATE: |
350 |
| - backend = "nodestore" |
351 |
| - else: |
352 |
| - backend = "indexedSpans" |
353 |
| - |
354 | 349 | transaction = request.query_params.get("transaction", None)
|
355 | 350 | http_method = request.query_params.get("http.method", None)
|
356 | 351 | if transaction is None:
|
357 | 352 | return Response(
|
358 | 353 | status=status.HTTP_400_BAD_REQUEST, data={"details": "Transaction not provided"}
|
359 | 354 | )
|
360 | 355 |
|
| 356 | + backend = request.query_params.get("backend", "nodestore") |
361 | 357 | sentry_sdk.set_tag("aggregate_spans.backend", backend)
|
362 | 358 |
|
| 359 | + if backend not in ALLOWED_BACKENDS: |
| 360 | + return Response( |
| 361 | + status=status.HTTP_400_BAD_REQUEST, data={"details": "Backend not supported"} |
| 362 | + ) |
| 363 | + |
363 | 364 | query = f"transaction:{transaction}"
|
364 | 365 | if http_method is not None:
|
365 | 366 | query += f" transaction.method:{http_method}"
|
|
0 commit comments