-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(logs): Without chart data when table is empty #103930
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
Merged
Zylphrex
merged 1 commit into
master
from
txiao/feat/withhold-chart-data-when-table-is-empty
Nov 25, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'], | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Getting a weird type error here about not able to assign |
||
| 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 = ( | ||
| <Widget.WidgetTitle title={prettifyAggregation(aggregate) ?? aggregate} /> | ||
|
|
@@ -204,9 +224,11 @@ function Graph({ | |
| visualize.visible && ( | ||
| <ConfidenceFooter | ||
| chartInfo={chartInfo} | ||
| isLoading={timeseriesResult.isLoading} | ||
| // hold off on showing the chart while the table is loading | ||
| isLoading={timeseriesResult.isLoading || tableIsPending} | ||
| rawLogCounts={rawLogCounts} | ||
| hasUserQuery={!!userQuery} | ||
| disabled={tableIsPending ? false : tableIsEmpty} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Chart data not withheld during Continue Scanning
When the user clicks
Continue Scanningwith existing table data, the chart data isn't withheld as intended. TheisPendingproperty fromuseLogsPageDataQueryResultonly includesisFetchingNextPagewhen data is empty. With existing data,isPendingremains false during pagination, sowithholdDatabecomes false, showing chart data while the table loads more results. This contradicts the PR's goal to withhold chart data duringContinue Scanningoperations. The code needs to also checkisFetchingNextPagein thewithholdDatacalculation.