Skip to content

Aggregate spans waterfall to indexed spans #69954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/sentry/api/endpoints/organization_spans_aggregation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hashlib
from collections import defaultdict, namedtuple
from collections.abc import Mapping
from datetime import datetime
from datetime import datetime, timezone
from typing import Any, Optional, TypedDict

import sentry_sdk
Expand All @@ -22,6 +22,7 @@
from sentry.utils.snuba import raw_snql_query

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

EventSpan = namedtuple(
"EventSpan",
Expand Down Expand Up @@ -336,31 +337,31 @@ class OrganizationSpansAggregationEndpoint(OrganizationEventsEndpointBase):
}

def get(self, request: Request, organization: Organization) -> Response:
if not features.has(
"organizations:starfish-aggregate-span-waterfall", organization, actor=request.user
):
if not features.has("organizations:spans-first-ui", organization, actor=request.user):
return Response(status=404)

try:
params = self.get_snuba_params(request, organization)
except NoProjects:
return Response(status=404)

force_nodestore = request.query_params.get("forceNodestore") == "true"

start = params["start"]
if start and start < CUTOVER_DATE or force_nodestore:
backend = "nodestore"
else:
backend = "indexedSpans"

transaction = request.query_params.get("transaction", None)
http_method = request.query_params.get("http.method", None)
if transaction is None:
return Response(
status=status.HTTP_400_BAD_REQUEST, data={"details": "Transaction not provided"}
)

backend = request.query_params.get("backend", "nodestore")
sentry_sdk.set_tag("aggregate_spans.backend", backend)

if backend not in ALLOWED_BACKENDS:
return Response(
status=status.HTTP_400_BAD_REQUEST, data={"details": "Backend not supported"}
)

query = f"transaction:{transaction}"
if http_method is not None:
query += f" transaction.method:{http_method}"
Expand Down
Loading
Loading