Skip to content
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

feat(explore): Use rpc layer behind toggle #81182

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions static/app/actionCreators/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export type EventQuery = {
referrer?: string;
sort?: string | string[];
team?: string | string[];
useRpc?: '1';
};

export type TagSegment = {
Expand Down
10 changes: 9 additions & 1 deletion static/app/utils/discover/eventView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1200,10 +1200,18 @@ 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;

if (eventQuery.useRpc !== '1') {
delete eventQuery.useRpc;
}

if (eventQuery.team && !eventQuery.team.length) {
delete eventQuery.team;
}
Expand Down
1 change: 1 addition & 0 deletions static/app/utils/discover/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
20 changes: 16 additions & 4 deletions static/app/views/explore/hooks/useDataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,39 @@ import {useNavigate} from 'sentry/utils/useNavigate';
interface Options {
location: Location;
navigate: ReturnType<typeof useNavigate>;
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) => {
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/explore/tables/aggregatesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
4 changes: 2 additions & 2 deletions static/app/views/explore/tables/spansTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -174,7 +174,7 @@ export function SpansTable({setError}: SpansTableProps) {
<IconWarning data-test-id="error-indicator" color="gray300" size="lg" />
</TableStatus>
) : result.isFetched && result.data?.length ? (
result.data?.map((row, i) => (
result.data?.slice(0, 50)?.map((row, i) => (
<TableRow key={i}>
{fields.map((field, j) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/explore/toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions static/app/views/explore/toolbar/toolbarDataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export function ToolbarDataset({dataset, setDataset}: ToolbarDatasetProps) {
<SegmentedControl.Item key={DiscoverDatasets.SPANS_EAP}>
{t('EAP Spans')}
</SegmentedControl.Item>
<SegmentedControl.Item key={DiscoverDatasets.SPANS_EAP_RPC}>
{t('EAP RPC Spans')}
</SegmentedControl.Item>
<SegmentedControl.Item key={DiscoverDatasets.SPANS_INDEXED}>
{t('Indexed Spans')}
</SegmentedControl.Item>
Expand Down
Loading