Skip to content

Commit 5e2cffe

Browse files
authored
feat(spans): Indexed spans for aggregate span waterfall (#69016)
Switch to using indexed spans instead of nodestore after a certain cutoff date (it's when the bloom filter index on transaction name was added to spans dataset) I'm going to follow up with proper tests for indexed spans since these tests were written before we had a way to store them for tests
1 parent 53ea03d commit 5e2cffe

File tree

2 files changed

+240
-154
lines changed

2 files changed

+240
-154
lines changed

src/sentry/api/endpoints/organization_spans_aggregation.py

Lines changed: 9 additions & 10 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
@@ -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,29 @@ 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+
start = params["start"]
349+
if start and start < CUTOVER_DATE:
350+
backend = "nodestore"
351+
else:
352+
backend = "indexedSpans"
353+
349354
transaction = request.query_params.get("transaction", None)
350355
http_method = request.query_params.get("http.method", None)
351356
if transaction is None:
352357
return Response(
353358
status=status.HTTP_400_BAD_REQUEST, data={"details": "Transaction not provided"}
354359
)
355360

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

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

0 commit comments

Comments
 (0)