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