@@ -4,6 +4,7 @@ import {Switch} from 'sentry/components/core/switch';
44import { Tooltip } from 'sentry/components/core/tooltip' ;
55import { t , tct } from 'sentry/locale' ;
66import { trackAnalytics } from 'sentry/utils/analytics' ;
7+ import { AggregationKey } from 'sentry/utils/fields' ;
78import useOrganization from 'sentry/utils/useOrganization' ;
89import usePageFilters from 'sentry/utils/usePageFilters' ;
910import usePrevious from 'sentry/utils/usePrevious' ;
@@ -21,15 +22,22 @@ import {
2122import { AutoRefreshLabel } from 'sentry/views/explore/logs/styles' ;
2223import { useLogsAutoRefreshInterval } from 'sentry/views/explore/logs/useLogsAutoRefreshInterval' ;
2324import { checkSortIsTimeBasedDescending } from 'sentry/views/explore/logs/utils' ;
24- import { useQueryParamsMode } from 'sentry/views/explore/queryParams/context' ;
25+ import {
26+ useQueryParamsMode ,
27+ useQueryParamsVisualizes ,
28+ } from 'sentry/views/explore/queryParams/context' ;
2529import { Mode } from 'sentry/views/explore/queryParams/mode' ;
30+ import type { Visualize } from 'sentry/views/explore/queryParams/visualize' ;
31+
32+ import { OurLogKnownFieldKey } from './types' ;
2633
2734const MAX_LOGS_PER_SECOND = 100 ; // Rate limit for initial check
2835
2936type PreFlightDisableReason =
3037 | 'sort' // Wrong sort order
3138 | 'absolute_time' // Using absolute date range
3239 | 'aggregates' // In aggregates view
40+ | 'unsupported_aggregation' // using an aggregate that's not `count(message)`
3341 | 'rate_limit_initial' // Too many logs per second
3442 | 'initial_error' ; // Initial table query errored
3543
@@ -55,6 +63,7 @@ export function AutorefreshToggle({averageLogsPerSecond = 0}: AutorefreshToggleP
5563 const setAutorefresh = useSetLogsAutoRefresh ( ) ;
5664 const sortBys = useLogsSortBys ( ) ;
5765 const mode = useQueryParamsMode ( ) ;
66+ const visualizes = useQueryParamsVisualizes ( ) ;
5867 const { selection} = usePageFilters ( ) ;
5968 const selectionString = JSON . stringify ( selection ) ;
6069 const previousSelection = usePrevious ( selectionString ) ;
@@ -79,6 +88,7 @@ export function AutorefreshToggle({averageLogsPerSecond = 0}: AutorefreshToggleP
7988 sortBys,
8089 hasAbsoluteDates,
8190 mode,
91+ visualizes,
8292 averageLogsPerSecond,
8393 initialIsError : isError ,
8494 } ) ;
@@ -127,18 +137,28 @@ function getPreFlightDisableReason({
127137 sortBys,
128138 hasAbsoluteDates,
129139 mode,
140+ visualizes,
130141 averageLogsPerSecond,
131142 initialIsError,
132143} : {
133144 hasAbsoluteDates : boolean ;
134145 mode : Mode ;
135146 sortBys : ReturnType < typeof useLogsSortBys > ;
147+ visualizes : readonly Visualize [ ] ;
136148 averageLogsPerSecond ?: number | null ;
137149 initialIsError ?: boolean ;
138150} ) : PreFlightDisableReason | null {
139151 if ( mode === Mode . AGGREGATE ) {
140152 return 'aggregates' ;
141153 }
154+ if (
155+ visualizes . some (
156+ visualize =>
157+ visualize . yAxis !== `${ AggregationKey . COUNT } (${ OurLogKnownFieldKey . MESSAGE } )`
158+ )
159+ ) {
160+ return 'unsupported_aggregation' ;
161+ }
142162 if ( ! checkSortIsTimeBasedDescending ( sortBys ) ) {
143163 return 'sort' ;
144164 }
@@ -185,6 +205,8 @@ function getTooltipMessage(
185205 ) ;
186206 case 'aggregates' :
187207 return t ( 'Auto-refresh is not available in the aggregates view.' ) ;
208+ case 'unsupported_aggregation' :
209+ return t ( 'Auto-refresh is only available when visualizing `count(logs)`.' ) ;
188210 case 'initial_error' :
189211 return t (
190212 'Auto-refresh is not available due to an error fetching logs. If the issue persists, please contact support.'
0 commit comments