From 08c47ae74313ca090a5a512e4d04ee886a181454 Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Fri, 22 Nov 2024 11:27:24 -0500 Subject: [PATCH 1/2] feat(explore): Use rpc layer behind toggle This adds the RPC layer behind the dataset toggle (which is feature flagged) so that we can start testing RPC calls. --- static/app/utils/discover/eventView.tsx | 6 +++++- static/app/utils/discover/types.tsx | 1 + static/app/views/explore/hooks/useDataset.tsx | 20 +++++++++++++++---- .../views/explore/tables/aggregatesTable.tsx | 2 +- .../app/views/explore/tables/spansTable.tsx | 4 ++-- static/app/views/explore/toolbar/index.tsx | 2 +- .../views/explore/toolbar/toolbarDataset.tsx | 3 +++ 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/static/app/utils/discover/eventView.tsx b/static/app/utils/discover/eventView.tsx index 5da719802fb10..174ea50d38101 100644 --- a/static/app/utils/discover/eventView.tsx +++ b/static/app/utils/discover/eventView.tsx @@ -1200,7 +1200,11 @@ class EventView { sort, per_page: DEFAULT_PER_PAGE, query: queryString, - dataset: this.dataset, + dataset: + this.dataset === DiscoverDatasets.SPANS_EAP_RPC + ? DiscoverDatasets.SPANS_EAP + : this.dataset, + useRpc: this.dataset === DiscoverDatasets.SPANS_EAP_RPC ? '1' : undefined, } ) as EventQuery & LocationQuery; diff --git a/static/app/utils/discover/types.tsx b/static/app/utils/discover/types.tsx index ddae415137a6f..33e4e63bda949 100644 --- a/static/app/utils/discover/types.tsx +++ b/static/app/utils/discover/types.tsx @@ -20,6 +20,7 @@ export enum DiscoverDatasets { METRICS_ENHANCED = 'metricsEnhanced', ISSUE_PLATFORM = 'issuePlatform', SPANS_EAP = 'spans', + SPANS_EAP_RPC = 'spansRpc', SPANS_INDEXED = 'spansIndexed', SPANS_METRICS = 'spansMetrics', TRANSACTIONS = 'transactions', diff --git a/static/app/views/explore/hooks/useDataset.tsx b/static/app/views/explore/hooks/useDataset.tsx index 58d85d43e7516..6e276672c60a8 100644 --- a/static/app/views/explore/hooks/useDataset.tsx +++ b/static/app/views/explore/hooks/useDataset.tsx @@ -9,27 +9,39 @@ import {useNavigate} from 'sentry/utils/useNavigate'; interface Options { location: Location; navigate: ReturnType; + allowRPC?: boolean; } -export function useDataset(): [DiscoverDatasets, (dataset: DiscoverDatasets) => void] { +interface UseDatasetOptions { + allowRPC?: boolean; +} + +export function useDataset( + options?: UseDatasetOptions +): [DiscoverDatasets, (dataset: DiscoverDatasets) => void] { const location = useLocation(); const navigate = useNavigate(); - const options = {location, navigate}; - return useDatasetImpl(options); + return useDatasetImpl({location, navigate, allowRPC: options?.allowRPC}); } function useDatasetImpl({ location, navigate, + allowRPC, }: Options): [DiscoverDatasets, (dataset: DiscoverDatasets) => void] { const dataset: DiscoverDatasets = useMemo(() => { const rawDataset = decodeScalar(location.query.dataset); if (rawDataset === 'spansIndexed') { return DiscoverDatasets.SPANS_INDEXED; } + + if (allowRPC && rawDataset === 'spansRpc') { + return DiscoverDatasets.SPANS_EAP_RPC; + } + return DiscoverDatasets.SPANS_EAP; - }, [location.query.dataset]); + }, [location.query.dataset, allowRPC]); const setDataset = useCallback( (newDataset: DiscoverDatasets) => { diff --git a/static/app/views/explore/tables/aggregatesTable.tsx b/static/app/views/explore/tables/aggregatesTable.tsx index cc1e9ffe41150..7b441cb79cbd2 100644 --- a/static/app/views/explore/tables/aggregatesTable.tsx +++ b/static/app/views/explore/tables/aggregatesTable.tsx @@ -57,7 +57,7 @@ export function AggregatesTable({setError}: AggregatesTableProps) { const {selection} = usePageFilters(); const topEvents = useTopEvents(); const organization = useOrganization(); - const [dataset] = useDataset(); + const [dataset] = useDataset({allowRPC: true}); const {groupBys} = useGroupBys(); const [visualizes] = useVisualizes(); const fields = useMemo(() => { diff --git a/static/app/views/explore/tables/spansTable.tsx b/static/app/views/explore/tables/spansTable.tsx index cbf4274f3902e..8e30821da6699 100644 --- a/static/app/views/explore/tables/spansTable.tsx +++ b/static/app/views/explore/tables/spansTable.tsx @@ -43,7 +43,7 @@ interface SpansTableProps { export function SpansTable({setError}: SpansTableProps) { const {selection} = usePageFilters(); - const [dataset] = useDataset(); + const [dataset] = useDataset({allowRPC: true}); const [fields] = useSampleFields(); const [sorts, setSorts] = useSorts({fields}); const [query] = useUserQuery(); @@ -174,7 +174,7 @@ export function SpansTable({setError}: SpansTableProps) { ) : result.isFetched && result.data?.length ? ( - result.data?.map((row, i) => ( + result.data?.slice(0, 50)?.map((row, i) => ( {fields.map((field, j) => { return ( diff --git a/static/app/views/explore/toolbar/index.tsx b/static/app/views/explore/toolbar/index.tsx index 3cd91cfe4d861..79942140513a0 100644 --- a/static/app/views/explore/toolbar/index.tsx +++ b/static/app/views/explore/toolbar/index.tsx @@ -19,7 +19,7 @@ interface ExploreToolbarProps { } export function ExploreToolbar({extras}: ExploreToolbarProps) { - const [dataset, setDataset] = useDataset(); + const [dataset, setDataset] = useDataset({allowRPC: true}); const [resultMode, setResultMode] = useResultMode(); const [sampleFields] = useSampleFields(); diff --git a/static/app/views/explore/toolbar/toolbarDataset.tsx b/static/app/views/explore/toolbar/toolbarDataset.tsx index 14711c6b59e77..3eadecb62654a 100644 --- a/static/app/views/explore/toolbar/toolbarDataset.tsx +++ b/static/app/views/explore/toolbar/toolbarDataset.tsx @@ -19,6 +19,9 @@ export function ToolbarDataset({dataset, setDataset}: ToolbarDatasetProps) { {t('EAP Spans')} + + {t('EAP RPC Spans')} + {t('Indexed Spans')} From 2cf3fb9b5fa6e721637d51a7de0b37231caa92ea Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Fri, 22 Nov 2024 11:52:35 -0500 Subject: [PATCH 2/2] fix tests --- static/app/actionCreators/events.tsx | 1 + static/app/utils/discover/eventView.tsx | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/static/app/actionCreators/events.tsx b/static/app/actionCreators/events.tsx index 07c6961908909..c9c53dbec3523 100644 --- a/static/app/actionCreators/events.tsx +++ b/static/app/actionCreators/events.tsx @@ -175,6 +175,7 @@ export type EventQuery = { referrer?: string; sort?: string | string[]; team?: string | string[]; + useRpc?: '1'; }; export type TagSegment = { diff --git a/static/app/utils/discover/eventView.tsx b/static/app/utils/discover/eventView.tsx index 174ea50d38101..e0dadd3768fe5 100644 --- a/static/app/utils/discover/eventView.tsx +++ b/static/app/utils/discover/eventView.tsx @@ -1208,6 +1208,10 @@ class EventView { } ) as EventQuery & LocationQuery; + if (eventQuery.useRpc !== '1') { + delete eventQuery.useRpc; + } + if (eventQuery.team && !eventQuery.team.length) { delete eventQuery.team; }