diff --git a/static/app/views/explore/logs/confidenceFooter.tsx b/static/app/views/explore/logs/confidenceFooter.tsx index e02da34d464467..e71f1fc09d06f9 100644 --- a/static/app/views/explore/logs/confidenceFooter.tsx +++ b/static/app/views/explore/logs/confidenceFooter.tsx @@ -16,6 +16,7 @@ interface ConfidenceFooterProps { hasUserQuery: boolean; isLoading: boolean; rawLogCounts: RawCounts; + disabled?: boolean; } export function ConfidenceFooter({ @@ -23,6 +24,7 @@ export function ConfidenceFooter({ hasUserQuery, isLoading, rawLogCounts, + disabled, }: ConfidenceFooterProps) { return ( @@ -35,6 +37,7 @@ export function ConfidenceFooter({ isSampled={chartInfo.isSampled} sampleCount={chartInfo.sampleCount} topEvents={chartInfo.topEvents} + disabled={disabled} /> ); @@ -46,6 +49,7 @@ interface ConfidenceMessageProps { rawLogCounts: RawCounts; confidence?: Confidence; dataScanned?: 'full' | 'partial'; + disabled?: boolean; isSampled?: boolean | null; sampleCount?: number; topEvents?: number; @@ -56,11 +60,16 @@ function ConfidenceMessage({ sampleCount, dataScanned, confidence: _confidence, + disabled, topEvents, hasUserQuery, isLoading, isSampled, }: ConfidenceMessageProps) { + if (disabled) { + return ; + } + if (isLoading || !defined(sampleCount)) { return ; } diff --git a/static/app/views/explore/logs/logsGraph.tsx b/static/app/views/explore/logs/logsGraph.tsx index 6de6db15a2fba3..cd5fdaf033229e 100644 --- a/static/app/views/explore/logs/logsGraph.tsx +++ b/static/app/views/explore/logs/logsGraph.tsx @@ -27,6 +27,8 @@ import { import {Widget} from 'sentry/views/dashboards/widgets/widget/widget'; import {handleAddQueryToDashboard} from 'sentry/views/discover/utils'; import {ChartVisualization} from 'sentry/views/explore/components/chart/chartVisualization'; +import type {ChartInfo} from 'sentry/views/explore/components/chart/types'; +import {useLogsPageDataQueryResult} from 'sentry/views/explore/contexts/logs/logsPageData'; import {formatSort} from 'sentry/views/explore/contexts/pageParamsContext/sortBys'; import { ChartIntervalUnspecifiedStrategy, @@ -119,6 +121,8 @@ function Graph({ timeseriesResult, visualize, }: GraphProps) { + const {isEmpty: tableIsEmpty, isPending: tableIsPending} = useLogsPageDataQueryResult(); + const aggregate = visualize.yAxis; const userQuery = useQueryParamsQuery(); const topEventsLimit = useQueryParamsTopEventsLimit(); @@ -127,14 +131,23 @@ function Graph({ unspecifiedStrategy: ChartIntervalUnspecifiedStrategy.USE_SMALLEST, }); - const chartInfo = useMemo(() => { - const series = timeseriesResult.data[aggregate] ?? []; + const chartInfo: ChartInfo = useMemo(() => { + // If the table is empty or pending, we want to withhold the chart data. + // This is to avoid a state where there is data in the chart but not in + // the table which is very weird. By withholding the chart data, we create + // the illusion the 2 are being queries in sync. + const withholdData = tableIsEmpty || tableIsPending; + + const series = withholdData ? [] : (timeseriesResult.data[aggregate] ?? []); const isTopEvents = defined(topEventsLimit); const samplingMeta = determineSeriesSampleCountAndIsSampled(series, isTopEvents); return { chartType: visualize.chartType, series, - timeseriesResult, + timeseriesResult: { + ...timeseriesResult, + isPending: timeseriesResult.isPending || tableIsPending, + } as ChartInfo['timeseriesResult'], yAxis: aggregate, confidence: combineConfidenceForSeries(series), dataScanned: samplingMeta.dataScanned, @@ -143,7 +156,14 @@ function Graph({ samplingMode: undefined, topEvents: isTopEvents ? TOP_EVENTS_LIMIT : undefined, }; - }, [visualize.chartType, timeseriesResult, aggregate, topEventsLimit]); + }, [ + visualize.chartType, + timeseriesResult, + aggregate, + topEventsLimit, + tableIsEmpty, + tableIsPending, + ]); const Title = ( @@ -204,9 +224,11 @@ function Graph({ visualize.visible && ( ) }