Skip to content

Commit

Permalink
feat(explore): Use spans dataset for traces list (#79492)
Browse files Browse the repository at this point in the history
This ensures that when using eap spans, the traces list also uses that
dataset.
  • Loading branch information
Zylphrex authored Oct 22, 2024
1 parent f75afc7 commit 500edcf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
4 changes: 4 additions & 0 deletions static/app/views/explore/hooks/useTraceSpans.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
import type {PageFilters} from 'sentry/types/core';
import type {DiscoverDatasets} from 'sentry/utils/discover/types';
import {useApiQuery} from 'sentry/utils/queryClient';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
Expand All @@ -16,6 +17,7 @@ export interface SpanResults<F extends string> {
interface UseTraceSpansOptions<F extends string> {
fields: F[];
trace: TraceResult;
dataset?: DiscoverDatasets;
datetime?: PageFilters['datetime'];
enabled?: boolean;
limit?: number;
Expand All @@ -26,6 +28,7 @@ interface UseTraceSpansOptions<F extends string> {
export function useTraceSpans<F extends string>({
fields,
trace,
dataset,
datetime,
enabled,
limit,
Expand All @@ -42,6 +45,7 @@ export function useTraceSpans<F extends string>({
project: selection.projects,
environment: selection.environments,
...normalizeDateTimeParams(datetime ?? selection.datetime),
dataset,
field: fields,
query,
sort,
Expand Down
5 changes: 4 additions & 1 deletion static/app/views/explore/hooks/useTraces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {useEffect} from 'react';
import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
import type {PageFilters} from 'sentry/types/core';
import {trackAnalytics} from 'sentry/utils/analytics';
import type {DiscoverDatasets} from 'sentry/utils/discover/types';
import {useApiQuery} from 'sentry/utils/queryClient';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
Expand Down Expand Up @@ -54,13 +55,14 @@ interface TraceResults {
}

interface UseTracesOptions {
dataset?: DiscoverDatasets;
datetime?: PageFilters['datetime'];
enabled?: boolean;
limit?: number;
query?: string | string[];
}

export function useTraces({datetime, enabled, limit, query}: UseTracesOptions) {
export function useTraces({dataset, datetime, enabled, limit, query}: UseTracesOptions) {
const organization = useOrganization();
const {projects} = useProjects();
const {selection} = usePageFilters();
Expand All @@ -72,6 +74,7 @@ export function useTraces({datetime, enabled, limit, query}: UseTracesOptions) {
project: selection.projects,
environment: selection.environments,
...normalizeDateTimeParams(datetime ?? selection.datetime),
dataset,
query,
per_page: limit,
breakdownSlices: BREAKDOWN_SLICES,
Expand Down
15 changes: 8 additions & 7 deletions static/app/views/explore/tables/tracesTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import useProjects from 'sentry/utils/useProjects';

import {type TraceResult, useTraces} from '../../hooks/useTraces';
import {useUserQuery} from '../../hooks/useUserQuery';

import {useDataset} from 'sentry/views/explore/hooks/useDataset';
import {type TraceResult, useTraces} from 'sentry/views/explore/hooks/useTraces';
import {useUserQuery} from 'sentry/views/explore/hooks/useUserQuery';
import {
Description,
ProjectBadgeWrapper,
ProjectsRenderer,
SpanTimeRenderer,
TraceBreakdownRenderer,
TraceIdRenderer,
} from './fieldRenderers';
import {SpanTable} from './spansTable';
} from 'sentry/views/explore/tables/tracesTable/fieldRenderers';
import {SpanTable} from 'sentry/views/explore/tables/tracesTable/spansTable';
import {
BreakdownPanelItem,
EmptyStateText,
Expand All @@ -41,11 +40,13 @@ import {
StyledPanelItem,
TracePanelContent,
WrappingText,
} from './styles';
} from 'sentry/views/explore/tables/tracesTable/styles';

export function TracesTable() {
const [dataset] = useDataset();
const [query] = useUserQuery();
const {data, isPending, isError} = useTraces({
dataset,
query,
limit: DEFAULT_PER_PAGE,
});
Expand Down
22 changes: 13 additions & 9 deletions static/app/views/explore/tables/tracesTable/spansTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ import type {Organization} from 'sentry/types/organization';
import {trackAnalytics} from 'sentry/utils/analytics';
import {getUtcDateString} from 'sentry/utils/dates';
import useOrganization from 'sentry/utils/useOrganization';

import type {TraceResult} from '../../hooks/useTraces';
import {type SpanResult, useTraceSpans} from '../../hooks/useTraceSpans';
import {useUserQuery} from '../../hooks/useUserQuery';

import {type Field, FIELDS, SORTS} from './data';
import {useDataset} from 'sentry/views/explore/hooks/useDataset';
import type {TraceResult} from 'sentry/views/explore/hooks/useTraces';
import {type SpanResult, useTraceSpans} from 'sentry/views/explore/hooks/useTraceSpans';
import {useUserQuery} from 'sentry/views/explore/hooks/useUserQuery';
import {type Field, FIELDS, SORTS} from 'sentry/views/explore/tables/tracesTable/data';
import {
SpanBreakdownSliceRenderer,
SpanDescriptionRenderer,
SpanIdRenderer,
SpanTimeRenderer,
TraceBreakdownContainer,
} from './fieldRenderers';
} from 'sentry/views/explore/tables/tracesTable/fieldRenderers';
import {
MoreMatchingSpans,
SpanPanelContent,
Expand All @@ -33,8 +32,11 @@ import {
StyledPanelHeader,
StyledPanelItem,
StyledSpanPanelItem,
} from './styles';
import {getSecondaryNameFromSpan, getStylingSliceName} from './utils';
} from 'sentry/views/explore/tables/tracesTable/styles';
import {
getSecondaryNameFromSpan,
getStylingSliceName,
} from 'sentry/views/explore/tables/tracesTable/utils';

const ONE_MINUTE = 60 * 1000; // in milliseconds

Expand All @@ -47,9 +49,11 @@ export function SpanTable({
}) {
const organization = useOrganization();

const [dataset] = useDataset();
const [query] = useUserQuery();

const {data, isPending, isError} = useTraceSpans({
dataset,
trace,
fields: [
...FIELDS,
Expand Down

0 comments on commit 500edcf

Please sign in to comment.