Skip to content

Commit a2cfcd5

Browse files
authored
fix(logs): Auto refresh should work with high fidelity mode (#103084)
High fidelity mode breaks autorefresh because it uses a different cursor. This means the 2 features cannot be used together. This change ensures that once auto refresh is turned on, high fidelity mode is turned off for the remainder of that session. Closes JAVASCRIPT-34DA Closes JAVASCRIPT-34G1
1 parent f465972 commit a2cfcd5

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

static/app/views/explore/contexts/logs/logsAutoRefreshContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export type AutoRefreshState =
3030

3131
interface LogsAutoRefreshContextValue {
3232
autoRefresh: AutoRefreshState;
33+
hasInitialized: boolean;
3334
isTableFrozen: boolean | undefined;
3435
pausedAt: number | undefined;
3536
refreshInterval: number;
@@ -87,6 +88,7 @@ export function LogsAutoRefreshProvider({
8788
isTableFrozen,
8889
pausedAt,
8990
setPausedAt,
91+
hasInitialized: hasInitialized.current,
9092
..._testContext,
9193
}}
9294
>

static/app/views/explore/logs/logsAutoRefresh.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {LogsQueryParamsProvider} from 'sentry/views/explore/logs/logsQueryParams
1414

1515
describe('LogsAutoRefresh Integration Tests', () => {
1616
const {organization, project, routerConfig, setupPageFilters, setupEventsMock} =
17-
initializeLogsTest();
17+
initializeLogsTest({orgFeatures: ['ourlogs-high-fidelity']});
1818

1919
const testDate = new Date('2024-01-15T10:00:00.000Z');
2020
const {baseFixtures} = createLogFixtures(organization, project, testDate);
@@ -48,7 +48,7 @@ describe('LogsAutoRefresh Integration Tests', () => {
4848
analyticsPageSource={LogsAnalyticsPageSource.EXPLORE_LOGS}
4949
source="location"
5050
>
51-
<LogsPageDataProvider>{children}</LogsPageDataProvider>
51+
<LogsPageDataProvider allowHighFidelity>{children}</LogsPageDataProvider>
5252
</LogsQueryParamsProvider>,
5353
options
5454
) as ReturnType<typeof render> & {router: any}; // Can't select the router type without exporting it.

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import {
1919
import {useLocation} from 'sentry/utils/useLocation';
2020
import useOrganization from 'sentry/utils/useOrganization';
2121
import usePageFilters from 'sentry/utils/usePageFilters';
22-
import {useLogsAutoRefreshEnabled} from 'sentry/views/explore/contexts/logs/logsAutoRefreshContext';
22+
import {
23+
useLogsAutoRefresh,
24+
useLogsAutoRefreshEnabled,
25+
} from 'sentry/views/explore/contexts/logs/logsAutoRefreshContext';
2326
import {SAMPLING_MODE} from 'sentry/views/explore/hooks/useProgressiveQuery';
2427
import {useTraceItemDetails} from 'sentry/views/explore/hooks/useTraceItemDetails';
2528
import {
@@ -405,6 +408,13 @@ export function useInfiniteLogsQuery({
405408
} = {}) {
406409
const _referrer = referrer ?? 'api.explore.logs-table';
407410
const autoRefresh = useLogsAutoRefreshEnabled();
411+
const {hasInitialized: autoRefreshHasInitialized} = useLogsAutoRefresh();
412+
413+
// High fidelity and auto refresh are disjoint features and cannot
414+
// be used together. So if auto refresh was ever initialized, we must
415+
// disable high fidelity mode.
416+
highFidelity = autoRefreshHasInitialized ? false : highFidelity;
417+
408418
const {queryKey: queryKeyWithInfinite, other} = useLogsQueryKeyWithInfinite({
409419
referrer: _referrer,
410420
autoRefresh,

0 commit comments

Comments
 (0)