SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix[logs][FE]: live tail is fixed (#1759)
Palash Gupta6c9036fbf4c6
diff --git a/frontend/src/components/Graph/xAxisConfig.ts b/frontend/src/components/Graph/xAxisConfig.tsindex d14d9bba09..ee794b6678 100644--- a/frontend/src/components/Graph/xAxisConfig.ts+++ b/frontend/src/components/Graph/xAxisConfig.ts@@ -4,9 +4,6 @@ import { useSelector } from 'react-redux';import { AppState } from 'store/reducers';import { GlobalReducer } from 'types/reducer/globalTime';-interface ITimeUnit {- [key: string]: TimeUnit;-}interface IAxisTimeUintConfig {unitName: TimeUnit;multiplier: number;@@ -22,7 +19,7 @@ export interface ITimeRange {maxTime: number | null;}-export const TIME_UNITS: ITimeUnit = {+export const TIME_UNITS: Record<TimeUnit, TimeUnit> = {millisecond: 'millisecond',second: 'second',minute: 'minute',@@ -31,6 +28,7 @@ export const TIME_UNITS: ITimeUnit = {week: 'week',month: 'month',year: 'year',+ quarter: 'quarter',};const TIME_UNITS_CONFIG: IAxisTimeUintConfig[] = [@@ -93,6 +91,7 @@ export const convertTimeRange = (} catch (error) {console.error(error);}+return {unitName: relevantTimeUnit.unitName,stepSize: Math.floor(stepSize) || 1,diff --git a/frontend/src/container/LogLiveTail/index.tsx b/frontend/src/container/LogLiveTail/index.tsxindex 1c48b4d8ab..1a4a38343d 100644--- a/frontend/src/container/LogLiveTail/index.tsx+++ b/frontend/src/container/LogLiveTail/index.tsx@@ -11,6 +11,7 @@ import { throttle } from 'lodash-es';import React, { useCallback, useEffect, useMemo, useRef } from 'react';import { useDispatch, useSelector } from 'react-redux';import { AppState } from 'store/reducers';+import { UPDATE_AUTO_REFRESH_DISABLED } from 'types/actions/globalTime';import {FLUSH_LOGS,PUSH_LIVE_TAIL_EVENT,@@ -19,6 +20,7 @@ import {} from 'types/actions/logs';import { TLogsLiveTailState } from 'types/api/logs/liveTail';import AppReducer from 'types/reducer/app';+import { GlobalReducer } from 'types/reducer/globalTime';import { ILogsReducer } from 'types/reducer/logs';import { TIME_PICKER_OPTIONS } from './config';@@ -34,12 +36,20 @@ function LogLiveTail(): JSX.Element {logs,} = useSelector<AppState, ILogsReducer>((state) => state.logs);const { isDarkMode } = useSelector<AppState, AppReducer>((state) => state.app);+ const { selectedAutoRefreshInterval } = useSelector<AppState, GlobalReducer>(+ (state) => state.globalTime,+ );+const dispatch = useDispatch();const handleLiveTail = (toggleState: TLogsLiveTailState): void => {dispatch({type: TOGGLE_LIVE_TAIL,payload: toggleState,});+ dispatch({+ type: UPDATE_AUTO_REFRESH_DISABLED,+ payload: toggleState === 'PLAYING',+ });};const batchedEventsRef = useRef<Record<string, unknown>[]>([]);@@ -131,6 +141,10 @@ function LogLiveTail(): JSX.Element {[dispatch, liveTail, liveTailStartRange],);+ const isDisabled = useMemo(() => selectedAutoRefreshInterval?.length > 0, [+ selectedAutoRefreshInterval,+ ]);+return (<TimePickerCard><Space size={0} align="center">@@ -149,6 +163,7 @@ function LogLiveTail(): JSX.Element {type="primary"onClick={handleLiveTailStart}title="Start live tail"+ disabled={isDisabled}>Go Live <PlayCircleOutlined /></Button>diff --git a/frontend/src/container/LogsAggregate/index.tsx b/frontend/src/container/LogsAggregate/index.tsxindex 737164f9fd..34200049c4 100644--- a/frontend/src/container/LogsAggregate/index.tsx+++ b/frontend/src/container/LogsAggregate/index.tsx@@ -31,6 +31,7 @@ function LogsAggregate({ getLogsAggregate }: LogsAggregateProps): JSX.Element {);const reFetchIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);+useEffect(() => {switch (liveTail) {case 'STOPPED': {@@ -38,18 +39,6 @@ function LogsAggregate({ getLogsAggregate }: LogsAggregateProps): JSX.Element {clearInterval(reFetchIntervalRef.current);}reFetchIntervalRef.current = null;- // getLogsAggregate({- // timestampStart: minTime,- // timestampEnd: maxTime,- // step: getStep({- // start: minTime,- // end: maxTime,- // inputFormat: 'ns',- // }),- // q: queryString,- // ...(idStart ? { idGt: idStart } : {}),- // ...(idEnd ? { idLt: idEnd } : {}),- // });break;}@@ -106,7 +95,7 @@ function LogsAggregate({ getLogsAggregate }: LogsAggregateProps): JSX.Element {}}type="bar"containerHeight="100%"- animate={false}+ animate/>)}</Container>diff --git a/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx b/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsxindex 6744c234da..1aab2e8e75 100644--- a/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx+++ b/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx@@ -21,7 +21,7 @@ import { v4 } from 'uuid';import { SearchFieldsProps } from '..';import FieldKey from '../FieldKey';-import { QueryConditionContainer, QueryFieldContainer } from '../styles';+import { QueryFieldContainer } from '../styles';import { createParsedQueryStructure } from '../utils';import { Container, QueryWrapper } from './styles';import { hashCode, parseQuery } from './utils';@@ -32,33 +32,27 @@ function QueryConditionField({query,queryIndex,onUpdate,- style,}: QueryConditionFieldProps): JSX.Element {+ const allOptions = Object.values(ConditionalOperators);return (- <QueryConditionContainer style={{ ...style }}>- <Select- defaultValue={- (query as any).value &&- (((query as any)?.value as any) as string).toUpperCase()- }- onChange={(e): void => {- onUpdate({ ...query, value: e }, queryIndex);- }}- >- {Object.values(ConditionalOperators).map((cond) => (- <Option key={cond} value={cond} label={cond}>- {cond}- </Option>- ))}- </Select>- </QueryConditionContainer>+ <Select+ defaultValue={+ (query as any).value &&+ (((query as any)?.value as any) as string).toUpperCase()+ }+ onChange={(e): void => {+ onUpdate({ ...query, value: e }, queryIndex);+ }}+ >+ {allOptions.map((cond) => (+ <Option key={cond} value={cond} label={cond}>+ {cond}+ </Option>+ ))}+ </Select>);}-QueryConditionField.defaultProps = {- style: undefined,-};-interface QueryFieldProps {query: Query;queryIndex: number;@@ -174,7 +168,6 @@ interface QueryConditionFieldProps {query: { value: string | string[]; type: string }[];queryIndex: number;onUpdate: (arg0: unknown, arg1: number) => void;- style?: React.CSSProperties;}export type Query = { value: string | string[]; type: string }[];@@ -233,12 +226,13 @@ function QueryBuilder({);return (- <QueryConditionField- key={keyPrefix + idx}- query={query}- queryIndex={idx}- onUpdate={handleUpdate as never}- />+ <div key={keyPrefix + idx}>+ <QueryConditionField+ query={query}+ queryIndex={idx}+ onUpdate={handleUpdate as never}+ />+ </div>);});diff --git a/frontend/src/container/LogsSearchFilter/SearchFields/styles.tsx b/frontend/src/container/LogsSearchFilter/SearchFields/styles.tsxindex 1f06e924ca..a826da07d4 100644--- a/frontend/src/container/LogsSearchFilter/SearchFields/styles.tsx+++ b/frontend/src/container/LogsSearchFilter/SearchFields/styles.tsx@@ -14,8 +14,3 @@ export const QueryFieldContainer = styled.div`background: ${blue[6]};}`;--export const QueryConditionContainer = styled.div`- display: flex;- flex-direction: row;-`;diff --git a/frontend/src/container/LogsSearchFilter/index.tsx b/frontend/src/container/LogsSearchFilter/index.tsxindex 5af48b17c1..cf71f3d3bd 100644--- a/frontend/src/container/LogsSearchFilter/index.tsx+++ b/frontend/src/container/LogsSearchFilter/index.tsx@@ -104,7 +104,8 @@ function SearchFilter({useEffect(() => {handleSearch(urlQueryString || '');- }, [handleSearch, urlQueryString]);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [urlQueryString, maxTime, minTime]);return (<Container>diff --git a/frontend/src/container/TopNav/AutoRefresh/index.tsx b/frontend/src/container/TopNav/AutoRefresh/index.tsxindex bc52e2cf86..aa6a74793c 100644--- a/frontend/src/container/TopNav/AutoRefresh/index.tsx+++ b/frontend/src/container/TopNav/AutoRefresh/index.tsx@@ -22,19 +22,28 @@ import { useInterval } from 'react-use';import { Dispatch } from 'redux';import { AppState } from 'store/reducers';import AppActions from 'types/actions';-import { UPDATE_TIME_INTERVAL } from 'types/actions/globalTime';+import {+ UPDATE_AUTO_REFRESH_INTERVAL,+ UPDATE_TIME_INTERVAL,+} from 'types/actions/globalTime';import { GlobalReducer } from 'types/reducer/globalTime';import { options } from './config';import { ButtonContainer, Container } from './styles';function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {- const { minTime: initialMinTime, selectedTime } = useSelector<- AppState,- GlobalReducer- >((state) => state.globalTime);+ const {+ minTime: initialMinTime,+ selectedTime,+ isAutoRefreshDisabled,+ } = useSelector<AppState, GlobalReducer>((state) => state.globalTime);const { pathname } = useLocation();+ const isDisabled = useMemo(() => disabled || isAutoRefreshDisabled, [+ isAutoRefreshDisabled,+ disabled,+ ]);+const localStorageData = JSON.parse(get(DASHBOARD_TIME_IN_DURATION) || '{}');const localStorageValue = useMemo(() => localStorageData[pathname], [@@ -46,13 +55,19 @@ function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {Boolean(localStorageValue),);+ const dispatch = useDispatch<Dispatch<AppActions>>();+useEffect(() => {- setIsAutoRefreshfreshEnabled(Boolean(localStorageValue));- }, [localStorageValue]);+ const isAutoRefreshEnabled = Boolean(localStorageValue);+ dispatch({+ type: UPDATE_AUTO_REFRESH_INTERVAL,+ payload: localStorageValue,+ });+ setIsAutoRefreshfreshEnabled(isAutoRefreshEnabled);+ }, [localStorageValue, dispatch]);const params = useUrlQuery();- const dispatch = useDispatch<Dispatch<AppActions>>();const [selectedOption, setSelectedOption] = useState<string>(localStorageValue || options[0].key,);@@ -69,7 +84,7 @@ function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {useInterval(() => {const selectedValue = getOption?.value;- if (disabled || !isAutoRefreshEnabled) {+ if (isDisabled || !isAutoRefreshEnabled) {return;}@@ -125,21 +140,23 @@ function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {<CheckboxonChange={onChangeAutoRefreshHandler}checked={isAutoRefreshEnabled}- disabled={disabled}+ disabled={isDisabled}>Auto Refresh</Checkbox><Divider />- <Typography.Paragraph>Refresh Interval</Typography.Paragraph>+ <Typography.Paragraph disabled={isDisabled}>+ Refresh Interval+ </Typography.Paragraph><Radio.Group onChange={onChangeHandler} value={selectedOption}><Space direction="vertical">{options.filter((e) => e.label !== 'off').map((option) => (- <Radio key={option.key} value={option.key}>+ <Radio disabled={isDisabled} key={option.key} value={option.key}>{option.label}</Radio>))}diff --git a/frontend/src/store/reducers/global.ts b/frontend/src/store/reducers/global.tsindex 896c6586e3..462076e54e 100644--- a/frontend/src/store/reducers/global.ts+++ b/frontend/src/store/reducers/global.ts@@ -2,6 +2,8 @@ import { getDefaultOption } from 'container/TopNav/DateTimeSelection/config';import {GLOBAL_TIME_LOADING_START,GlobalTimeAction,+ UPDATE_AUTO_REFRESH_DISABLED,+ UPDATE_AUTO_REFRESH_INTERVAL,UPDATE_TIME_INTERVAL,} from 'types/actions/globalTime';import { GlobalReducer } from 'types/reducer/globalTime';@@ -13,6 +15,8 @@ const intitalState: GlobalReducer = {selectedTime: getDefaultOption(typeof window !== 'undefined' ? window?.location?.pathname : '',),+ isAutoRefreshDisabled: false,+ selectedAutoRefreshInterval: '',};const globalTimeReducer = (@@ -35,6 +39,20 @@ const globalTimeReducer = (};}+ case UPDATE_AUTO_REFRESH_DISABLED: {+ return {+ ...state,+ isAutoRefreshDisabled: action.payload,+ };+ }++ case UPDATE_AUTO_REFRESH_INTERVAL: {+ return {+ ...state,+ selectedAutoRefreshInterval: action.payload,+ };+ }+default:return state;}diff --git a/frontend/src/store/reducers/logs.ts b/frontend/src/store/reducers/logs.tsindex a170de66e3..5e1dc69977 100644--- a/frontend/src/store/reducers/logs.ts+++ b/frontend/src/store/reducers/logs.ts@@ -106,7 +106,6 @@ export const LogsReducer = (}${action.payload}`;const updatedParsedQuery = parseQuery(updatedQueryString);- console.log({ updatedParsedQuery, updatedQueryString, action });return {...state,searchFilter: {diff --git a/frontend/src/types/actions/globalTime.ts b/frontend/src/types/actions/globalTime.tsindex 8e384fb569..8ce1ff3963 100644--- a/frontend/src/types/actions/globalTime.ts+++ b/frontend/src/types/actions/globalTime.ts@@ -2,6 +2,8 @@ import { Time } from 'container/TopNav/DateTimeSelection/config';export const UPDATE_TIME_INTERVAL = 'UPDATE_TIME_INTERVAL';export const GLOBAL_TIME_LOADING_START = 'GLOBAL_TIME_LOADING_START';+export const UPDATE_AUTO_REFRESH_DISABLED = 'UPDATE_AUTO_REFRESH_DISABLED';+export const UPDATE_AUTO_REFRESH_INTERVAL = 'UPDATE_AUTO_REFRESH_INTERVAL';export type GlobalTime = {maxTime: number;@@ -17,8 +19,22 @@ interface UpdateTimeInterval {payload: UpdateTime;}+interface UpdateAutoRefreshDisabled {+ type: typeof UPDATE_AUTO_REFRESH_DISABLED;+ payload: boolean;+}+interface GlobalTimeLoading {type: typeof GLOBAL_TIME_LOADING_START;}-export type GlobalTimeAction = UpdateTimeInterval | GlobalTimeLoading;+interface UpdateAutoRefreshInterval {+ type: typeof UPDATE_AUTO_REFRESH_INTERVAL;+ payload: string;+}++export type GlobalTimeAction =+ | UpdateTimeInterval+ | GlobalTimeLoading+ | UpdateAutoRefreshDisabled+ | UpdateAutoRefreshInterval;diff --git a/frontend/src/types/reducer/globalTime.ts b/frontend/src/types/reducer/globalTime.tsindex cb55524c75..94bb17eb73 100644--- a/frontend/src/types/reducer/globalTime.ts+++ b/frontend/src/types/reducer/globalTime.ts@@ -6,4 +6,6 @@ export interface GlobalReducer {minTime: GlobalTime['minTime'];loading: boolean;selectedTime: Time;+ isAutoRefreshDisabled: boolean;+ selectedAutoRefreshInterval: string;}