Skip to content

Commit 0d6dd4f

Browse files
authored
Aggregate spans waterfall to indexed spans (#69954)
Reopening #69016 basically updated slightly to use options to enable/disable indexed spans
1 parent e755cab commit 0d6dd4f

File tree

3 files changed

+258
-155
lines changed

3 files changed

+258
-155
lines changed

src/sentry/api/endpoints/organization_spans_aggregation.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import hashlib
22
from collections import defaultdict, namedtuple
33
from collections.abc import Mapping
4-
from datetime import datetime
4+
from datetime import datetime, timezone
55
from typing import Any, Optional, TypedDict
66

77
import sentry_sdk
@@ -10,7 +10,7 @@
1010
from rest_framework.response import Response
1111
from snuba_sdk import Column, Function
1212

13-
from sentry import eventstore, features
13+
from sentry import eventstore, features, options
1414
from sentry.api.api_publish_status import ApiPublishStatus
1515
from sentry.api.base import region_silo_endpoint
1616
from sentry.api.bases import NoProjects, OrganizationEventsEndpointBase
@@ -22,6 +22,7 @@
2222
from sentry.utils.snuba import raw_snql_query
2323

2424
ALLOWED_BACKENDS = ["indexedSpans", "nodestore"]
25+
CUTOVER_DATE = datetime(2024, 3, 22, tzinfo=timezone.utc)
2526

2627
EventSpan = namedtuple(
2728
"EventSpan",
@@ -336,31 +337,31 @@ class OrganizationSpansAggregationEndpoint(OrganizationEventsEndpointBase):
336337
}
337338

338339
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):
342341
return Response(status=404)
343342

344343
try:
345344
params = self.get_snuba_params(request, organization)
346345
except NoProjects:
347346
return Response(status=404)
348347

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+
349356
transaction = request.query_params.get("transaction", None)
350357
http_method = request.query_params.get("http.method", None)
351358
if transaction is None:
352359
return Response(
353360
status=status.HTTP_400_BAD_REQUEST, data={"details": "Transaction not provided"}
354361
)
355362

356-
backend = request.query_params.get("backend", "nodestore")
357363
sentry_sdk.set_tag("aggregate_spans.backend", backend)
358364

359-
if backend not in ALLOWED_BACKENDS:
360-
return Response(
361-
status=status.HTTP_400_BAD_REQUEST, data={"details": "Backend not supported"}
362-
)
363-
364365
query = f"transaction:{transaction}"
365366
if http_method is not None:
366367
query += f" transaction.method:{http_method}"

src/sentry/options/defaults.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,11 @@
23732373
default=False,
23742374
flags=FLAG_PRIORITIZE_DISK | FLAG_AUTOMATOR_MODIFIABLE,
23752375
)
2376+
register(
2377+
"indexed-spans.agg-span-waterfall.enable",
2378+
default=False,
2379+
flags=FLAG_PRIORITIZE_DISK | FLAG_AUTOMATOR_MODIFIABLE,
2380+
)
23762381

23772382
# Deobfuscate profiles using Symbolicator
23782383
register(

0 commit comments

Comments
 (0)