Skip to content

Commit 403f4ff

Browse files
cursoragentarmenzg
andcommitted
fix(logs): Correct inverted maxPages condition for infinite query
The ternary condition in maxPagesForLogsInfiniteQuery was inverted. When there are fewer than 500 rows locally, we should use the higher limit (300 pages) to collect sufficient data from sparse logs. When there are more rows cached, use the lower limit (30 pages) to conserve memory. Also fixed the JSDoc comment on LOCAL_LOG_ROWS_FOR_EXPANDED_INFINITE_PAGES to correctly reference MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED. Co-authored-by: Armen Zambrano G. <armenzg@users.noreply.github.com>
1 parent aec7539 commit 403f4ff

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

static/app/views/explore/logs/constants.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const DEFAULT_TRACE_ITEM_HOVER_TIMEOUT_WITH_AUTO_REFRESH = 400; // With a
2222
export const MAX_LOGS_INFINITE_QUERY_PAGES = 30; // This number * the refresh interval must be more seconds than 2 * the smallest time interval in the chart for streaming to work.
2323
/** Larger page cap once enough rows are cached (see useInfiniteLogsQuery). */
2424
export const MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED = 300;
25-
/** Below this many rows in the client cache, use {@link MAX_LOGS_INFINITE_QUERY_PAGES}. */
25+
/** Below this many rows in the client cache, use {@link MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED}. */
2626
export const LOCAL_LOG_ROWS_FOR_EXPANDED_INFINITE_PAGES = 500;
2727

2828
/**

static/app/views/explore/logs/useLogsQuery.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ function maxPagesForLogsInfiniteQuery(client: QueryClient, queryKey: QueryKey):
414414
const rows =
415415
cached?.pages?.reduce((n, page) => n + (page[0]?.data?.length ?? 0), 0) ?? 0;
416416
return rows < LOCAL_LOG_ROWS_FOR_EXPANDED_INFINITE_PAGES
417-
? MAX_LOGS_INFINITE_QUERY_PAGES
418-
: MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED;
417+
? MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED
418+
: MAX_LOGS_INFINITE_QUERY_PAGES;
419419
}
420420

421421
export function useInfiniteLogsQuery({

0 commit comments

Comments
 (0)