From 500edcf44bbedc4dd0b91b3f9c12df288630a895 Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Tue, 22 Oct 2024 15:26:23 -0400 Subject: [PATCH] feat(explore): Use spans dataset for traces list (#79492) This ensures that when using eap spans, the traces list also uses that dataset. --- .../app/views/explore/hooks/useTraceSpans.tsx | 4 ++++ static/app/views/explore/hooks/useTraces.tsx | 5 ++++- .../explore/tables/tracesTable/index.tsx | 15 +++++++------ .../explore/tables/tracesTable/spansTable.tsx | 22 +++++++++++-------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/static/app/views/explore/hooks/useTraceSpans.tsx b/static/app/views/explore/hooks/useTraceSpans.tsx index 016bbb338ff4db..a225ee4a562e03 100644 --- a/static/app/views/explore/hooks/useTraceSpans.tsx +++ b/static/app/views/explore/hooks/useTraceSpans.tsx @@ -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'; @@ -16,6 +17,7 @@ export interface SpanResults { interface UseTraceSpansOptions { fields: F[]; trace: TraceResult; + dataset?: DiscoverDatasets; datetime?: PageFilters['datetime']; enabled?: boolean; limit?: number; @@ -26,6 +28,7 @@ interface UseTraceSpansOptions { export function useTraceSpans({ fields, trace, + dataset, datetime, enabled, limit, @@ -42,6 +45,7 @@ export function useTraceSpans({ project: selection.projects, environment: selection.environments, ...normalizeDateTimeParams(datetime ?? selection.datetime), + dataset, field: fields, query, sort, diff --git a/static/app/views/explore/hooks/useTraces.tsx b/static/app/views/explore/hooks/useTraces.tsx index 9283510a8fed38..200241af2b21d1 100644 --- a/static/app/views/explore/hooks/useTraces.tsx +++ b/static/app/views/explore/hooks/useTraces.tsx @@ -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'; @@ -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(); @@ -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, diff --git a/static/app/views/explore/tables/tracesTable/index.tsx b/static/app/views/explore/tables/tracesTable/index.tsx index 3d8d418bbcf720..d660f4b04d4757 100644 --- a/static/app/views/explore/tables/tracesTable/index.tsx +++ b/static/app/views/explore/tables/tracesTable/index.tsx @@ -19,10 +19,9 @@ 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, @@ -30,8 +29,8 @@ import { 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, @@ -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, }); diff --git a/static/app/views/explore/tables/tracesTable/spansTable.tsx b/static/app/views/explore/tables/tracesTable/spansTable.tsx index 1feaf1779818ff..7794ce0d4c2e7f 100644 --- a/static/app/views/explore/tables/tracesTable/spansTable.tsx +++ b/static/app/views/explore/tables/tracesTable/spansTable.tsx @@ -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, @@ -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 @@ -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,