|
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
|
|
10 | 10 | from rest_framework.response import Response
|
11 | 11 | from snuba_sdk import Column, Function
|
12 | 12 |
|
13 |
| -from sentry import eventstore, features |
| 13 | +from sentry import eventstore, features, options |
14 | 14 | from sentry.api.api_publish_status import ApiPublishStatus
|
15 | 15 | from sentry.api.base import region_silo_endpoint
|
16 | 16 | from sentry.api.bases import NoProjects, OrganizationEventsEndpointBase
|
|
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,31 @@ 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 | + enable_indexed_spans = options.get("indexed-spans.agg-span-waterfall.enable") |
| 349 | + |
| 350 | + start = params["start"] |
| 351 | + if start and start >= CUTOVER_DATE and enable_indexed_spans: |
| 352 | + backend = "indexedSpans" |
| 353 | + else: |
| 354 | + backend = "nodestore" |
| 355 | + |
349 | 356 | transaction = request.query_params.get("transaction", None)
|
350 | 357 | http_method = request.query_params.get("http.method", None)
|
351 | 358 | if transaction is None:
|
352 | 359 | return Response(
|
353 | 360 | status=status.HTTP_400_BAD_REQUEST, data={"details": "Transaction not provided"}
|
354 | 361 | )
|
355 | 362 |
|
356 |
| - backend = request.query_params.get("backend", "nodestore") |
357 | 363 | sentry_sdk.set_tag("aggregate_spans.backend", backend)
|
358 | 364 |
|
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 | 365 | query = f"transaction:{transaction}"
|
365 | 366 | if http_method is not None:
|
366 | 367 | query += f" transaction.method:{http_method}"
|
|
0 commit comments