Skip to content

Commit

Permalink
Revert "feat(eap): Use RPC to fetch tag values (#77510)"
Browse files Browse the repository at this point in the history
This reverts commit a8e4e05.

Co-authored-by: Zylphrex <10239353+Zylphrex@users.noreply.github.com>
  • Loading branch information
getsentry-bot and Zylphrex committed Sep 27, 2024
1 parent f611127 commit bb3cbc3
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 385 deletions.
67 changes: 1 addition & 66 deletions src/sentry/api/endpoints/organization_spans_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from rest_framework.request import Request
from rest_framework.response import Response
from sentry_protos.snuba.v1alpha.endpoint_tags_list_pb2 import (
AttributeValuesRequest,
AttributeValuesResponse,
TraceItemAttributesRequest,
TraceItemAttributesResponse,
)
Expand All @@ -22,7 +20,6 @@
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import region_silo_endpoint
from sentry.api.bases import NoProjects, OrganizationEventsV2EndpointBase
from sentry.api.event_search import translate_escape_sequences
from sentry.api.paginator import ChainPaginator
from sentry.api.serializers import serialize
from sentry.api.utils import handle_query_errors
Expand Down Expand Up @@ -198,68 +195,6 @@ def get(self, request: Request, organization, key: str) -> Response:

max_span_tag_values = options.get("performance.spans-tags-values.max")

serializer = OrganizationSpansFieldsEndpointSerializer(data=request.GET)
if not serializer.is_valid():
return Response(serializer.errors, status=400)
serialized = serializer.validated_data

if serialized["dataset"] == "spans" and features.has(
"organizations:visibility-explore-dataset", organization, actor=request.user
):
start_timestamp = Timestamp()
start_timestamp.FromDatetime(
snuba_params.start_date.replace(hour=0, minute=0, second=0, microsecond=0)
)

end_timestamp = Timestamp()
end_timestamp.FromDatetime(
snuba_params.end_date.replace(hour=0, minute=0, second=0, microsecond=0)
+ timedelta(days=1)
)

query = translate_escape_sequences(request.GET.get("query", ""))
rpc_request = AttributeValuesRequest(
meta=RequestMeta(
organization_id=organization.id,
cogs_category="performance",
referrer=Referrer.API_SPANS_TAG_VALUES_RPC.value,
project_ids=snuba_params.project_ids,
start_timestamp=start_timestamp,
end_timestamp=end_timestamp,
trace_item_name=TraceItemName.TRACE_ITEM_NAME_EAP_SPANS,
),
name=key,
value_substring_match=query,
limit=max_span_tag_values,
offset=0,
)
rpc_response = snuba.rpc(rpc_request, AttributeValuesResponse)

paginator = ChainPaginator(
[
[
TagValue(
key=key,
value=tag_value,
times_seen=None,
first_seen=None,
last_seen=None,
)
for tag_value in rpc_response.values
if tag_value
]
],
max_limit=max_span_tag_values,
)

return self.paginate(
request=request,
paginator=paginator,
on_results=lambda results: serialize(results, request.user),
default_per_page=max_span_tag_values,
max_per_page=max_span_tag_values,
)

executor = SpanFieldValuesAutocompletionExecutor(
snuba_params=snuba_params,
key=key,
Expand Down Expand Up @@ -404,7 +339,7 @@ def get_autocomplete_query_base(self) -> BaseQueryBuilder:

def get_autocomplete_results(self, query: BaseQueryBuilder) -> list[TagValue]:
with handle_query_errors():
results = query.process_results(query.run_query(Referrer.API_SPANS_TAG_VALUES.value))
results = query.process_results(query.run_query(Referrer.API_SPANS_TAG_KEYS.value))

return [
TagValue(
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/snuba/referrer.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,6 @@ class Referrer(Enum):
API_TRACE_EXPLORER_TRACE_SPANS_LIST = "api.trace-explorer.trace-spans-list"
API_SPANS_TAG_KEYS = "api.spans.tags-keys"
API_SPANS_TAG_KEYS_RPC = "api.spans.tags-keys.rpc"
API_SPANS_TAG_VALUES = "api.spans.tags-values"
API_SPANS_TAG_VALUES_RPC = "api.spans.tags-values.rpc"
API_SPANS_TRACE_VIEW = "api.spans.trace-view"

# Performance Mobile UI Module
Expand Down
Loading

0 comments on commit bb3cbc3

Please sign in to comment.