Skip to content

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.

feat(ai-observability): Trace view changes (#12796)

Gaurav Tewarif6f41df237f7
diff --git a/frontend/src/api/querySuggestions/types.ts b/frontend/src/api/querySuggestions/types.ts
index 717c427ef2..b37c73f163 100644
--- a/frontend/src/api/querySuggestions/types.ts
+++ b/frontend/src/api/querySuggestions/types.ts
@@ -1,21 +1,15 @@
import type {
GetAIObservabilityFieldsKeys200,
GetAIObservabilityFieldsValues200,
- GetAIObservabilityFieldsKeysParams,
- GetAIObservabilityFieldsValuesParams,
GetFieldsKeys200,
GetFieldsKeysParams,
GetFieldsValues200,
GetFieldsValuesParams,
} from 'api/generated/services/sigNoz.schemas';
-export type FieldKeysConfig =
- | GetFieldsKeysParams
- | GetAIObservabilityFieldsKeysParams;
+export type FieldKeysConfig = GetFieldsKeysParams;
-export type FieldValuesConfig =
- | GetFieldsValuesParams
- | GetAIObservabilityFieldsValuesParams;
+export type FieldValuesConfig = GetFieldsValuesParams;
export type FieldKeysConfigProp = Omit<
FieldKeysConfig,
diff --git a/frontend/src/container/LLMObservability/Explorer/Explorer.tsx b/frontend/src/container/LLMObservability/Explorer/Explorer.tsx
index 31ca77a3b0..a97042f054 100644
--- a/frontend/src/container/LLMObservability/Explorer/Explorer.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/Explorer.tsx
@@ -10,16 +10,10 @@ import QueryCancelledPlaceholder from 'components/QueryCancelledPlaceholder';
import QuickFilters from 'components/QuickFilters/QuickFilters';
import { QuickFiltersSource, SignalType } from 'components/QuickFilters/types';
import WarningPopover from 'components/WarningPopover/WarningPopover';
-import { AVAILABLE_EXPORT_PANEL_TYPES } from 'constants/panelTypes';
-import { initialQueryAIWithType, PANEL_TYPES } from 'constants/queryBuilder';
+import { initialQueryAIWithType } from 'constants/queryBuilder';
import { usePageActions } from 'container/AIAssistant/pageActions/usePageActions';
-import ExplorerOptionWrapper from 'container/ExplorerOptions/ExplorerOptionWrapper';
-import { useOptionsMenu } from 'container/OptionsMenu';
-import LeftToolbarActions from 'container/QueryBuilder/components/ToolbarActions/LeftToolbarActions';
import RightToolbarActions from 'container/QueryBuilder/components/ToolbarActions/RightToolbarActions';
import Toolbar from 'container/Toolbar/Toolbar';
-import { ExportDashboard } from 'hooks/dashboard/useExportDashboards';
-import { useGetExportToDashboardLink } from 'hooks/dashboard/useGetExportToDashboardLink';
import { useGetPanelTypesQueryParam } from 'hooks/queryBuilder/useGetPanelTypesQueryParam';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { useShareBuilderUrl } from 'hooks/queryBuilder/useShareBuilderUrl';
@@ -28,7 +22,6 @@ import {
useHandleExplorerTabChange,
} from 'hooks/useHandleExplorerTabChange';
import { useIsAIAssistantEnabled } from 'hooks/useIsAIAssistantEnabled';
-import { useSafeNavigate } from 'hooks/useSafeNavigate';
import { isEmpty } from 'lodash-es';
import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback';
import { ExplorerViews } from 'pages/LogsExplorer/utils';
@@ -37,7 +30,7 @@ import {
tracesChangeViewAction,
tracesRunQueryAction,
tracesSaveViewAction,
-} from 'pages/TracesExplorer/aiActions';
+} from './aiActions';
import { Warning } from 'types/api';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
import { DataSource } from 'types/common/queryBuilder';
@@ -45,12 +38,10 @@ import {
explorerViewToPanelType,
getExplorerViewFromUrl,
} from 'utils/explorerUtils';
-import { v4 } from 'uuid';
-import { TOOLBAR_VIEWS } from './constants';
-import { getExportQueryData, getQueryByPanelType } from './explorerUtils';
+import LeftToolbarActions from '../ToolbarActions/LeftToolbarActions';
+import { DEFAULT_PANEL_TYPE, TOOLBAR_VIEWS } from './constants';
import ListView from './ListView/ListView';
-import { defaultSelectedColumns } from './ListView/configs';
import QuerySection from './QuerySection/QuerySection';
import TableView from './TableView/TableView';
import TimeSeriesView from './TimeSeriesView/TimeSeriesView';
@@ -60,7 +51,6 @@ import './Explorer.styles.scss';
function Explorer(): JSX.Element {
const {
- panelType,
updateAllQueriesOperators,
handleRunQuery,
stagedQuery,
@@ -72,20 +62,12 @@ function Explorer(): JSX.Element {
const isAIAssistantEnabled = useIsAIAssistantEnabled();
- const { options } = useOptionsMenu({
- dataSource: DataSource.TRACES,
- aggregateOperator: 'noop',
- initialOptions: {
- selectColumns: defaultSelectedColumns,
- },
- });
-
const [searchParams] = useSearchParams();
const queryClient = useQueryClient();
const listQueryKeyRef = useRef<any>();
// Get panel type from URL
- const panelTypesFromUrl = useGetPanelTypesQueryParam(PANEL_TYPES.LIST);
+ const panelTypesFromUrl = useGetPanelTypesQueryParam(DEFAULT_PANEL_TYPE);
const [isLoadingQueries, setIsLoadingQueries] = useState<boolean>(false);
const [isCancelled, setIsCancelled] = useState(false);
@@ -116,15 +98,13 @@ function Explorer(): JSX.Element {
(): Query =>
updateAllQueriesOperators(
initialQueryAIWithType,
- PANEL_TYPES.LIST,
+ DEFAULT_PANEL_TYPE,
DataSource.TRACES,
),
[updateAllQueriesOperators],
);
const { handleExplorerTabChange } = useHandleExplorerTabChange();
- const { safeNavigate } = useSafeNavigate();
- const getExportToDashboardLink = useGetExportToDashboardLink();
const handleChangeSelectedView = useCallback(
(view: ExplorerViews, querySearchParameters?: ICurrentQueryData): void => {
@@ -139,7 +119,7 @@ function Explorer(): JSX.Element {
},
[handleExplorerTabChange, handleSetConfig],
);
-
+ //TODO: check if we need to enable AI Assistant page actions on LLM o11y
// ─── AI Assistant page actions (only when license feature is on) ───────────
const aiActions = useMemo(
() =>
@@ -179,59 +159,6 @@ function Explorer(): JSX.Element {
usePageActions('traces-explorer', aiActions);
// ───────────────────────────────────────────────────────────────────────────
- const exportDefaultQuery = useMemo(
- () =>
- getQueryByPanelType(
- stagedQuery || initialQueryAIWithType,
- panelType || PANEL_TYPES.LIST,
- ),
- [stagedQuery, panelType],
- );
-
- const handleExport = useCallback(
- (dashboard: ExportDashboard | null, isNewDashboard?: boolean): void => {
- if (!dashboard || !panelType) {
- return;
- }
-
- const panelTypeParam = AVAILABLE_EXPORT_PANEL_TYPES.includes(panelType)
- ? panelType
- : PANEL_TYPES.TIME_SERIES;
-
- const widgetId = v4();
-
- const query = getExportQueryData(
- exportDefaultQuery,
- panelTypeParam,
- options,
- );
-
- logEvent('Traces Explorer: Add to dashboard successful', {
- panelType,
- isNewDashboard,
- dashboardName: dashboard?.title,
- });
-
- const dashboardEditView = getExportToDashboardLink({
- query,
- panelType: panelTypeParam,
- dashboardId: dashboard.id,
- widgetId,
- });
-
- if (dashboardEditView) {
- safeNavigate(dashboardEditView);
- }
- },
- [
- exportDefaultQuery,
- panelType,
- safeNavigate,
- options,
- getExportToDashboardLink,
- ],
- );
-
useShareBuilderUrl({ defaultValue: defaultQuery });
const logEventCalledRef = useRef(false);
@@ -354,14 +281,6 @@ function Explorer(): JSX.Element {
</div>
)}
</div>
-
- <ExplorerOptionWrapper
- disabled={!stagedQuery}
- query={exportDefaultQuery}
- sourcepage={DataSource.TRACES}
- onExport={handleExport}
- handleChangeSelectedView={handleChangeSelectedView}
- />
</div>
</div>
</Sentry.ErrorBoundary>
diff --git a/frontend/src/container/LLMObservability/Explorer/ListView/ListView.tsx b/frontend/src/container/LLMObservability/Explorer/ListView/ListView.tsx
index 50f19e7079..1e545bce20 100644
--- a/frontend/src/container/LLMObservability/Explorer/ListView/ListView.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/ListView/ListView.tsx
@@ -12,25 +12,17 @@ import { QueryKey } from 'react-query';
// eslint-disable-next-line no-restricted-imports
import { useSelector } from 'react-redux';
import logEvent from 'api/common/logEvent';
-import DownloadOptionsMenu from 'components/DownloadOptionsMenu/DownloadOptionsMenu';
import ListViewOrderBy from 'components/OrderBy/ListViewOrderBy';
import type { TableColumnDef } from 'components/TanStackTableView/types';
import { ENTITY_VERSION_V5 } from 'constants/app';
+import { LOCALSTORAGE } from 'constants/localStorage';
import { QueryParams } from 'constants/query';
import { initialQueryAIWithType, PANEL_TYPES } from 'constants/queryBuilder';
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
-import { useOptionsMenu } from 'container/OptionsMenu';
import { CustomTimeType } from 'container/TopNav/DateTimeSelectionV2/types';
-import TraceExplorerControls from 'container/TracesExplorer/Controls';
-import {
- getTraceLink,
- transformSpanRows,
-} from 'container/TracesExplorer/ListView/utils';
-import {
- getFieldColumn,
- TracesTableRow,
-} from 'container/TracesExplorer/TracesTable/getFieldColumn';
-import TracesTable from 'container/TracesExplorer/TracesTable/TracesTable';
+import { getTraceLink, transformSpanRows } from './utils';
+import { getFieldColumn, TracesTableRow } from '../TracesTable/getFieldColumn';
+import TracesTable from '../TracesTable/TracesTable';
import { useGetQueryRange } from 'hooks/queryBuilder/useGetQueryRange';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { Pagination } from 'hooks/queryPagination';
@@ -42,6 +34,7 @@ import { Warning } from 'types/api';
import { DataSource } from 'types/common/queryBuilder';
import { GlobalReducer } from 'types/reducer/globalTime';
+import TraceExplorerControls from '../Controls';
import { getListViewQuery } from '../explorerUtils';
import {
defaultSelectedColumns,
@@ -79,14 +72,6 @@ function ListView({
loading: timeRangeUpdateLoading,
} = useSelector<AppState, GlobalReducer>((state) => state.globalTime);
- const { options, config } = useOptionsMenu({
- dataSource: DataSource.TRACES,
- aggregateOperator: 'count',
- initialOptions: {
- selectColumns: defaultSelectedColumns,
- },
- });
-
const { queryData: paginationQueryData } = useUrlQueryData<Pagination>(
QueryParams.pagination,
);
@@ -98,19 +83,6 @@ function ListView({
[stagedQuery, orderBy],
);
- // Stable sorted-name signature for the queryKey.
- // - Drag updates selectColumns; raw queryKey would churn on reorder.
- // - Trace API fetches only listed columns → add/remove must refetch.
- // - Sorted-name signature: stable on reorder, changes on add/remove.
- const selectColumnsSignature = useMemo(
- () =>
- (options?.selectColumns ?? [])
- .map((c) => c.name)
- .sort()
- .join(','),
- [options?.selectColumns],
- );
-
const queryKey = useMemo(
() => [
REACT_QUERY_KEY.GET_QUERY_RANGE,
@@ -120,7 +92,6 @@ function ListView({
stagedQuery,
panelType,
paginationConfig,
- selectColumnsSignature,
orderBy,
],
[
@@ -128,7 +99,6 @@ function ListView({
panelType,
globalSelectedTime,
paginationConfig,
- selectColumnsSignature,
maxTime,
minTime,
orderBy,
@@ -150,7 +120,7 @@ function ListView({
},
tableParams: {
pagination: paginationConfig,
- selectColumns: options?.selectColumns,
+ selectColumns: defaultSelectedColumns,
},
},
ENTITY_VERSION_V5,
@@ -158,10 +128,7 @@ function ListView({
queryKey,
enabled:
// don't make api call while the time range state in redux is loading
- !timeRangeUpdateLoading &&
- !!stagedQuery &&
- panelType === PANEL_TYPES.LIST &&
- !!options?.selectColumns?.length,
+ !timeRangeUpdateLoading && !!stagedQuery && panelType === PANEL_TYPES.LIST,
},
);
@@ -186,28 +153,20 @@ function ListView({
[queryTableDataResult],
);
- const columns = useMemo<TableColumnDef<TracesTableRow>[]>(() => {
- const fields = [
- TIMESTAMP_FIELD,
- ...(options?.selectColumns ?? []).filter(
- (field) => field.name !== TIMESTAMP_FIELD.name,
+ // TODO(ai-explorer): static columns until the preferences framework lands.
+ const columns = useMemo<TableColumnDef<TracesTableRow>[]>(
+ () =>
+ [TIMESTAMP_FIELD, ...defaultSelectedColumns].map((field) =>
+ getFieldColumn(field),
),
- ];
- return fields.map((field) => getFieldColumn(field));
- }, [options?.selectColumns]);
+ [],
+ );
const rows = useMemo(
() => transformSpanRows(queryTableData),
[queryTableData],
);
- const handleColumnOrderChange = useCallback(
- (reordered: TableColumnDef<TracesTableRow>[]): void => {
- config?.addColumn?.onReorder(reordered.map((column) => column.id));
- },
- [config],
- );
-
const handleOrderChange = useCallback((value: string) => {
setOrderBy(value);
}, []);
@@ -235,15 +194,9 @@ function ListView({
/>
</div>
- <DownloadOptionsMenu
- dataSource={DataSource.TRACES}
- selectedColumns={options?.selectColumns}
- />
-
<TraceExplorerControls
isLoading={isFetching}
totalCount={rows.length}
- config={config}
perPageOptions={PER_PAGE_OPTIONS}
/>
</div>
@@ -251,6 +204,8 @@ function ListView({
<TracesTable
data={rows}
columns={columns}
+ columnStorageKey={LOCALSTORAGE.AI_OBSERVABILITY_LIST_COLUMNS}
+ respectColumnOrder
panelType="LIST"
getRowHref={getTraceLink}
isLoading={isLoading}
@@ -258,8 +213,6 @@ function ListView({
isError={isError}
error={error}
isFilterApplied={isFilterApplied}
- onColumnOrderChange={handleColumnOrderChange}
- onColumnRemove={config?.addColumn?.onRemove}
/>
</div>
);
diff --git a/frontend/src/container/LLMObservability/Explorer/ListView/configs.ts b/frontend/src/container/LLMObservability/Explorer/ListView/configs.ts
index 11d6a5a9b8..9fe5c369b7 100644
--- a/frontend/src/container/LLMObservability/Explorer/ListView/configs.ts
+++ b/frontend/src/container/LLMObservability/Explorer/ListView/configs.ts
@@ -1,19 +1,41 @@
import type { TelemetryFieldKey } from 'api/v5/v5';
import { DEFAULT_PER_PAGE_OPTIONS } from 'hooks/queryPagination';
-export const defaultSelectedColumns: string[] = [
- 'service.name',
- 'name',
- 'duration_nano',
- 'http_method',
- 'response_status_code',
- 'timestamp',
-];
-
-export const PER_PAGE_OPTIONS: number[] = [10, ...DEFAULT_PER_PAGE_OPTIONS];
-
// Pinned timestamp column
+// The list query returns timestamp, trace_id and span_id whether or not they are selected.
export const TIMESTAMP_FIELD = {
name: 'timestamp',
fieldContext: 'span',
} as TelemetryFieldKey;
+
+export const defaultSelectedColumns: TelemetryFieldKey[] = [
+ {
+ name: 'service.name',
+ signal: 'traces',
+ fieldContext: 'resource',
+ fieldDataType: 'string',
+ },
+ {
+ name: 'name',
+ signal: 'traces',
+ fieldContext: 'span',
+ fieldDataType: 'string',
+ },
+ {
+ name: 'duration_nano',
+ signal: 'traces',
+ fieldContext: 'span',
+ },
+ {
+ name: 'http_method',
+ signal: 'traces',
+ fieldContext: 'span',
+ },
+ {
+ name: 'response_status_code',
+ signal: 'traces',
+ fieldContext: 'span',
+ },
+];
+
+export const PER_PAGE_OPTIONS: number[] = [10, ...DEFAULT_PER_PAGE_OPTIONS];
diff --git a/frontend/src/container/LLMObservability/Explorer/ListView/utils.tsx b/frontend/src/container/LLMObservability/Explorer/ListView/utils.tsx
index 78e71017d7..1295f14a12 100644
--- a/frontend/src/container/LLMObservability/Explorer/ListView/utils.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/ListView/utils.tsx
@@ -1,47 +1,8 @@
-import { Link } from 'react-router-dom';
-import type { TableColumnsType as ColumnsType } from 'antd';
-import { Badge } from '@signozhq/ui/badge';
-import { Typography } from '@signozhq/ui/typography';
-import { TelemetryFieldKey } from 'api/v5/v5';
import type { TracesTableRow } from '../TracesTable/getFieldColumn';
-import { DATE_TIME_FORMATS } from 'constants/dateTimeFormats';
import ROUTES from 'constants/routes';
-import { buildCompositeKey } from 'container/OptionsMenu/utils';
-import { getMs } from 'container/Trace/Filters/Panel/PanelBody/Duration/util';
import { formUrlParams } from 'container/TraceDetail/utils';
-import { TimestampInput } from 'hooks/useTimezoneFormatter/useTimezoneFormatter';
-import { RowData } from 'lib/query/createTableColumnsFromQuery';
-import LineClampedText from 'periscope/components/LineClampedText/LineClampedText';
-import { ILog } from 'types/api/logs/log';
import { QueryDataV3 } from 'types/api/widgets/getQuery';
-export function BlockLink({
- children,
- to,
- openInNewTab,
-}: {
- children: React.ReactNode;
- to: string;
- openInNewTab: boolean;
-}): any {
- // Display block to make the whole cell clickable
- return (
- <Link
- to={to}
- style={{ display: 'block' }}
- target={openInNewTab ? '_blank' : '_self'}
- >
- {children}
- </Link>
- );
-}
-
-export const transformDataWithDate = (
- data: QueryDataV3[],
-): Omit<ILog, 'timestamp'>[] =>
- data[0]?.list?.map(({ data, timestamp }) => ({ ...data, date: timestamp })) ||
- [];
-
export const getTraceLink = (record: Record<string, unknown>): string => {
function readId(value: unknown): string {
if (typeof value === 'string' || typeof value === 'number') {
@@ -60,95 +21,6 @@ export const getTraceLink = (record: Record<string, unknown>): string => {
})}`;
};
-export const getListColumns = (
- selectedColumns: TelemetryFieldKey[],
- formatTimezoneAdjustedTimestamp: (
- input: TimestampInput,
- format?: string,
- ) => string | number,
-): ColumnsType<RowData> => {
- const initialColumns: ColumnsType<RowData> = [
- {
- dataIndex: 'date',
- key: 'date',
- title: 'Timestamp',
- width: 145,
- render: (value, item): JSX.Element => {
- const date =
- typeof value === 'string'
- ? formatTimezoneAdjustedTimestamp(
- value,
- DATE_TIME_FORMATS.ISO_DATETIME_MS,
- )
- : formatTimezoneAdjustedTimestamp(
- value / 1e6,
- DATE_TIME_FORMATS.ISO_DATETIME_MS,
- );
- return (
- <BlockLink to={getTraceLink(item)} openInNewTab={false}>
- <Typography.Text>{date}</Typography.Text>
- </BlockLink>
- );
- },
- },
- ];
-
- const columns: ColumnsType<RowData> =
- selectedColumns.map((props) => {
- const name = props?.name || (props as any)?.key;
- const fieldContext = props?.fieldContext || (props as any)?.type;
- return {
- title: name,
- dataIndex: name,
- key: buildCompositeKey(name, fieldContext),
- width: 145,
- render: (value, item): JSX.Element => {
- if (value === '') {
- return (
- <BlockLink to={getTraceLink(item)} openInNewTab={false}>
- <Typography data-testid={name}>N/A</Typography>
- </BlockLink>
- );
- }
-
- if (
- name === 'httpMethod' ||
- name === 'responseStatusCode' ||
- name === 'response_status_code' ||
- name === 'http_method'
- ) {
- return (
- <BlockLink to={getTraceLink(item)} openInNewTab={false}>
- <Badge data-testid={name} color="sakura" variant="outline">
- {value}
- </Badge>
- </BlockLink>
- );
- }
-
- if (name === 'durationNano' || name === 'duration_nano') {
- return (
- <BlockLink to={getTraceLink(item)} openInNewTab={false}>
- <Typography data-testid={name}>{getMs(value)}ms</Typography>
- </BlockLink>
- );
- }
-
- return (
- <BlockLink to={getTraceLink(item)} openInNewTab={false}>
- <Typography data-testid={name}>
- <LineClampedText text={value} lines={3} />
- </Typography>
- </BlockLink>
- );
- },
- responsive: ['md'],
- };
- }) || [];
-
- return [...initialColumns, ...columns];
-};
-
// Reshapes the query-range list payload into table rows. `id` mirrors span_id so
// TanStack sees genuine row changes on orderBy toggles instead of falling back to
// positional ids; `timestamp` is lifted from the wrapping ListItem.
diff --git a/frontend/src/container/LLMObservability/Explorer/QuerySection/QuerySection.tsx b/frontend/src/container/LLMObservability/Explorer/QuerySection/QuerySection.tsx
index 124767cfc8..1b77c8c30d 100644
--- a/frontend/src/container/LLMObservability/Explorer/QuerySection/QuerySection.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/QuerySection/QuerySection.tsx
@@ -4,8 +4,10 @@ import { PANEL_TYPES } from 'constants/queryBuilder';
import { useGetPanelTypesQueryParam } from 'hooks/queryBuilder/useGetPanelTypesQueryParam';
import { DataSource } from 'types/common/queryBuilder';
+import { DEFAULT_PANEL_TYPE } from '../constants';
+
function QuerySection(): JSX.Element {
- const panelTypes = useGetPanelTypesQueryParam(PANEL_TYPES.LIST);
+ const panelTypes = useGetPanelTypesQueryParam(DEFAULT_PANEL_TYPE);
const isRawQuery = useMemo(
() => panelTypes === PANEL_TYPES.LIST || panelTypes === PANEL_TYPES.TRACE,
diff --git a/frontend/src/container/LLMObservability/Explorer/TableView/TableView.tsx b/frontend/src/container/LLMObservability/Explorer/TableView/TableView.tsx
index 7e049d8e0a..92b2a03bc7 100644
--- a/frontend/src/container/LLMObservability/Explorer/TableView/TableView.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/TableView/TableView.tsx
@@ -107,7 +107,7 @@ function TableView({
dataSource={DataSource.TRACES}
data={data}
query={stagedQuery || initialQueriesMap.traces}
- fileName="traces-table"
+ fileName="ai-traces-table"
/>
</div>
)}
diff --git a/frontend/src/container/LLMObservability/Explorer/TimeSeriesView/TimeSeriesView.tsx b/frontend/src/container/LLMObservability/Explorer/TimeSeriesView/TimeSeriesView.tsx
index 4f200cc94f..bec538317c 100644
--- a/frontend/src/container/LLMObservability/Explorer/TimeSeriesView/TimeSeriesView.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/TimeSeriesView/TimeSeriesView.tsx
@@ -126,6 +126,7 @@ function TimeSeriesViewContainer({
dataSource={dataSource}
setWarning={setWarning}
allowExport
+ exportFileName="ai-traces-timeseries"
/>
</div>
);
diff --git a/frontend/src/container/LLMObservability/Explorer/TracesTable/TracesTable.tsx b/frontend/src/container/LLMObservability/Explorer/TracesTable/TracesTable.tsx
index 34736037ce..a994fe312c 100644
--- a/frontend/src/container/LLMObservability/Explorer/TracesTable/TracesTable.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/TracesTable/TracesTable.tsx
@@ -55,6 +55,9 @@ function TracesTable({
const isDataAbsent =
!isLoading && !isFetching && !isError && data.length === 0;
+ // Rows can land before the field keys, and mounting then renders a partial column set.
+ const canMountTable = !isError && !isLoading && data.length !== 0;
+
const handleRowClick = useCallback(
(row: TracesTableRow): void => {
history.push(getRowHref(row));
@@ -83,7 +86,7 @@ function TracesTable({
<EmptyLogsSearch dataSource={DataSource.TRACES} panelType={panelType} />
)}
- {!isError && data.length !== 0 && (
+ {canMountTable && (
<div className={styles.tableWrapper}>
<TanStackTable<TracesTableRow>
data={data}
diff --git a/frontend/src/container/LLMObservability/Explorer/TracesTable/__tests__/TracesTable.test.tsx b/frontend/src/container/LLMObservability/Explorer/TracesTable/__tests__/TracesTable.test.tsx
new file mode 100644
index 0000000000..3b4ed7b7aa
--- /dev/null
+++ b/frontend/src/container/LLMObservability/Explorer/TracesTable/__tests__/TracesTable.test.tsx
@@ -0,0 +1,72 @@
+import { useState } from 'react';
+import { useColumnStore } from 'components/TanStackTableView/useColumnStore';
+import { LOCALSTORAGE } from 'constants/localStorage';
+import { render, screen, userEvent } from 'tests/test-utils';
+
+import { buildTraceViewColumns } from '../../TracesView/configs';
+import TracesTable from '../TracesTable';
+
+const STORAGE_KEY = LOCALSTORAGE.AI_OBSERVABILITY_TRACE_VIEW_COLUMNS;
+const PERSISTED_KEY = `@signoz/table-columns/${STORAGE_KEY}`;
+
+const ROWS = [{ id: 't1', trace_id: 'abc', 'service.name': 'checkout' }];
+
+const COLUMNS = buildTraceViewColumns([
+ { name: 'trace_id' },
+ { name: 'service.name', fieldContext: 'resource' },
+ { name: 'start_time' },
+]);
+
+function RaceHarness(): JSX.Element {
+ const [columnsReady, setColumnsReady] = useState(false);
+
+ return (
+ <>
+ <button type="button" onClick={(): void => setColumnsReady(true)}>
+ columns-ready
+ </button>
+ <TracesTable
+ data={ROWS}
+ columns={columnsReady ? COLUMNS : []}
+ columnStorageKey={STORAGE_KEY}
+ respectColumnOrder
+ panelType="TRACE"
+ getRowHref={(): string => '/trace/abc'}
+ isLoading={!columnsReady}
+ isFetching={false}
+ isError={false}
+ error={null}
+ isFilterApplied={false}
+ />
+ </>
+ );
+}
+
+const persistedState = (): { hiddenColumnIds: string[] } | null => {
+ const raw = localStorage.getItem(PERSISTED_KEY);
+ return raw ? (JSON.parse(raw) as { hiddenColumnIds: string[] }) : null;
+};
+
+describe('TracesTable column-init race', () => {
+ beforeEach(() => {
+ useColumnStore.setState({ tables: {} });
+ localStorage.clear();
+ });
+
+ it('does not persist empty defaults when rows land before columns', async () => {
+ const user = userEvent.setup({ pointerEventsCheck: 0 });
+ render(<RaceHarness />);
+
+ expect(screen.getByText(/pending_data_placeholder/i)).toBeInTheDocument();
+ expect(screen.queryByRole('table')).not.toBeInTheDocument();
+ expect(useColumnStore.getState().tables[STORAGE_KEY]).toBeUndefined();
+ expect(persistedState()).toBeNull();
+
+ await user.click(screen.getByRole('button', { name: 'columns-ready' }));
+
+ await expect(screen.findByRole('table')).resolves.toBeInTheDocument();
+ expect(screen.getByText('trace_id')).toBeInTheDocument();
+ expect(screen.queryByText('start_time')).not.toBeInTheDocument();
+ expect(persistedState()?.hiddenColumnIds).toStrictEqual(['start_time']);
+ });
+});
diff --git a/frontend/src/container/LLMObservability/Explorer/TracesTable/constants.ts b/frontend/src/container/LLMObservability/Explorer/TracesTable/constants.ts
index 6a911eaa23..0cb5dee797 100644
--- a/frontend/src/container/LLMObservability/Explorer/TracesTable/constants.ts
+++ b/frontend/src/container/LLMObservability/Explorer/TracesTable/constants.ts
@@ -1,6 +1,13 @@
// Field-name allowlists that drive signal-specific cell rendering. Both legacy
// camelCase and snake_case variants are listed because the API has shipped both.
-export const TIMESTAMP_FIELD_NAMES = new Set(['timestamp']);
+
+// start/end/last_activity_time come from the per-trace query, unlike span timestamp.
+export const TIMESTAMP_FIELD_NAMES = new Set([
+ 'timestamp',
+ 'start_time',
+ 'end_time',
+ 'last_activity_time',
+]);
export const STATUS_FIELD_NAMES = new Set([
'httpMethod',
@@ -13,6 +20,12 @@ export const STATUS_FIELD_NAMES = new Set([
'http.response.status_code',
]);
-export const DURATION_FIELD_NAMES = new Set(['durationNano', 'duration_nano']);
+// trace_/max_llm_duration_nano are trace-level durations the per-trace query computes.
+export const DURATION_FIELD_NAMES = new Set([
+ 'durationNano',
+ 'duration_nano',
+ 'trace_duration_nano',
+ 'max_llm_duration_nano',
+]);
export const TRACE_ID_FIELD_NAMES = new Set(['traceID', 'trace_id']);
diff --git a/frontend/src/container/LLMObservability/Explorer/TracesView/TracesView.tsx b/frontend/src/container/LLMObservability/Explorer/TracesView/TracesView.tsx
index ef7528e4fc..efa18bc863 100644
--- a/frontend/src/container/LLMObservability/Explorer/TracesView/TracesView.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/TracesView/TracesView.tsx
@@ -67,6 +67,7 @@ function TracesView({
onFieldsChange,
requiredFields,
isLoading: isColumnsLoading,
+ canPersistColumns,
} = useTraceViewColumns();
const {
@@ -168,9 +169,22 @@ function TracesView({
setOrderBy(value);
}, []);
+ // Without the full column set there is no pool to pick from, so the control is dropped.
const fieldsSelectorConfig = useMemo(
- () => ({ fieldsSelector: { value: selectedFields, onFieldsChange } }),
- [selectedFields, onFieldsChange],
+ () =>
+ canPersistColumns
+ ? { fieldsSelector: { value: selectedFields, onFieldsChange } }
+ : null,
+ [canPersistColumns, selectedFields, onFieldsChange],
+ );
+
+ // Rendering the pool unfiltered would surface columns the defaults keep hidden.
+ const tableColumns = useMemo(
+ () =>
+ canPersistColumns
+ ? columns
+ : columns.filter((column) => column.defaultVisibility !== false),
+ [canPersistColumns, columns],
);
return (
@@ -207,8 +221,12 @@ function TracesView({
<TracesTable
data={rows}
- columns={columns}
- columnStorageKey={LOCALSTORAGE.AI_OBSERVABILITY_TRACE_VIEW_COLUMNS}
+ columns={tableColumns}
+ columnStorageKey={
+ canPersistColumns
+ ? LOCALSTORAGE.AI_OBSERVABILITY_TRACE_VIEW_COLUMNS
+ : undefined
+ }
respectColumnOrder
panelType="TRACE"
getRowHref={getTraceLink}
diff --git a/frontend/src/container/LLMObservability/Explorer/TracesView/__tests__/TracesView.test.tsx b/frontend/src/container/LLMObservability/Explorer/TracesView/__tests__/TracesView.test.tsx
new file mode 100644
index 0000000000..e5dfb128b4
--- /dev/null
+++ b/frontend/src/container/LLMObservability/Explorer/TracesView/__tests__/TracesView.test.tsx
@@ -0,0 +1,190 @@
+import { ENVIRONMENT } from 'constants/env';
+import { server } from 'mocks-server/server';
+import { rest } from 'msw';
+import { render, screen, waitFor } from 'tests/test-utils';
+import {
+ TelemetrytypesFieldContextDTO,
+ TelemetrytypesFieldDataTypeDTO,
+} from 'api/generated/services/sigNoz.schemas';
+import { useColumnStore } from 'components/TanStackTableView/useColumnStore';
+import { LOCALSTORAGE } from 'constants/localStorage';
+import { initialQueryAIWithType, PANEL_TYPES } from 'constants/queryBuilder';
+
+import TracesView from '../TracesView';
+
+const STORAGE_KEY = LOCALSTORAGE.AI_OBSERVABILITY_TRACE_VIEW_COLUMNS;
+const PERSISTED_KEY = `@signoz/table-columns/${STORAGE_KEY}`;
+const QUERY_RANGE_URL = `${ENVIRONMENT.baseURL}/api/v5/query_range`;
+const FIELD_KEYS_URL = `${ENVIRONMENT.baseURL}/api/v1/ai_observability/fields/keys`;
+
+const OPTIONS_TRIGGER = 'options_menu.options';
+
+const ROWS = [
+ {
+ timestamp: '2024-07-19T08:39:58.735245Z',
+ data: {
+ 'service.name': 'checkout',
+ root_span_name: 'HTTP GET',
+ trace_duration_nano: 55306000,
+ span_count: 8,
+ trace_id: '0000000000000000344ded1387b08a7e',
+ },
+ },
+];
+
+const mockRows = (): void => {
+ server.use(
+ rest.post(QUERY_RANGE_URL, (_req, res, ctx) =>
+ res(
+ ctx.status(200),
+ ctx.json({
+ data: {
+ type: 'trace',
+ data: { results: [{ queryName: 'A', rows: ROWS }] },
+ },
+ }),
+ ),
+ ),
+ );
+};
+
+const mockFieldKeys = (names: string[]): void => {
+ server.use(
+ rest.get(FIELD_KEYS_URL, (_req, res, ctx) =>
+ res(
+ ctx.status(200),
+ ctx.json({
+ status: 'success',
+ data: {
+ complete: true,
+ keys: Object.fromEntries(
+ names.map((name) => [
+ name,
+ [
+ {
+ name,
+ fieldContext: TelemetrytypesFieldContextDTO.trace,
+ fieldDataType: TelemetrytypesFieldDataTypeDTO.float64,
+ },
+ ],
+ ]),
+ ),
+ },
+ }),
+ ),
+ ),
+ );
+};
+
+const mockFieldKeysFailure = (): void => {
+ server.use(
+ rest.get(FIELD_KEYS_URL, (_req, res, ctx) =>
+ res(ctx.status(500), ctx.json({ status: 'error' })),
+ ),
+ );
+};
+
+const persistedState = (): { hiddenColumnIds: string[] } | null => {
+ const raw = localStorage.getItem(PERSISTED_KEY);
+ return raw ? (JSON.parse(raw) as { hiddenColumnIds: string[] }) : null;
+};
+
+const renderTracesView = (): ReturnType<typeof render> =>
+ render(
+ <TracesView
+ isFilterApplied={false}
+ setWarning={jest.fn()}
+ setIsLoadingQueries={jest.fn()}
+ />,
+ {},
+ {
+ initialRoute: '/llm-observability/traces',
+ queryBuilderOverrides: {
+ panelType: PANEL_TYPES.TRACE,
+ stagedQuery: initialQueryAIWithType,
+ currentQuery: initialQueryAIWithType,
+ } as never,
+ },
+ );
+
+describe('TracesView column persistence', () => {
+ beforeEach(() => {
+ useColumnStore.setState({ tables: {} });
+ localStorage.clear();
+ mockRows();
+ });
+
+ afterEach(() => {
+ server.resetHandlers();
+ });
+
+ // Rows are virtualised, so a mounted table stands in for "rows arrived".
+ const findTable = (): Promise<HTMLElement> => screen.findByRole('table');
+
+ it('seeds the persisted defaults once the field keys arrive', async () => {
+ mockFieldKeys(['llm_call_count', 'tool_call_count']);
+ renderTracesView();
+
+ await findTable();
+
+ await waitFor(() => {
+ expect(persistedState()?.hiddenColumnIds).toStrictEqual([
+ 'start_time',
+ 'end_time',
+ 'error_count',
+ 'input',
+ 'output',
+ 'trace:tool_call_count:float64',
+ ]);
+ });
+ expect(screen.getByText(OPTIONS_TRIGGER)).toBeInTheDocument();
+ expect(screen.getByText('llm_call_count')).toBeInTheDocument();
+ });
+
+ it('persists nothing when the field keys fail', async () => {
+ mockFieldKeysFailure();
+ renderTracesView();
+
+ await findTable();
+
+ expect(useColumnStore.getState().tables[STORAGE_KEY]).toBeUndefined();
+ expect(persistedState()).toBeNull();
+ });
+
+ it('drops the column picker when the field keys fail', async () => {
+ mockFieldKeysFailure();
+ renderTracesView();
+
+ await findTable();
+
+ expect(screen.queryByText(OPTIONS_TRIGGER)).not.toBeInTheDocument();
+ });
+
+ it('renders only the default-visible columns when the field keys fail', async () => {
+ mockFieldKeysFailure();
+ renderTracesView();
+
+ await findTable();
+
+ expect(screen.getByText('root_span_name')).toBeInTheDocument();
+ expect(screen.getByText('trace_id')).toBeInTheDocument();
+ expect(screen.queryByText('input')).not.toBeInTheDocument();
+ expect(screen.queryByText('output')).not.toBeInTheDocument();
+ });
+
+ it('leaves an existing selection untouched while the field keys fail', async () => {
+ const existing = {
+ hiddenColumnIds: ['trace:tool_call_count:float64', 'input', 'output'],
+ columnOrder: ['trace_id', 'resource:service.name'],
+ columnSizing: {},
+ };
+ localStorage.setItem(PERSISTED_KEY, JSON.stringify(existing));
+
+ mockFieldKeysFailure();
+ renderTracesView();
+
+ await findTable();
+
+ expect(persistedState()).toStrictEqual(existing);
+ });
+});
diff --git a/frontend/src/container/LLMObservability/Explorer/TracesView/__tests__/useTraceViewColumns.test.tsx b/frontend/src/container/LLMObservability/Explorer/TracesView/__tests__/useTraceViewColumns.test.tsx
index 5424ac3bcb..2af77a4b2e 100644
--- a/frontend/src/container/LLMObservability/Explorer/TracesView/__tests__/useTraceViewColumns.test.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/TracesView/__tests__/useTraceViewColumns.test.tsx
@@ -149,6 +149,62 @@ describe('useTraceViewColumns', () => {
);
});
+ describe('when the keys fetch fails', () => {
+ beforeEach(() => {
+ server.use(
+ rest.get(
+ `${ENVIRONMENT.baseURL}/api/v1/ai_observability/fields/keys`,
+ (_req, res, ctx) => res(ctx.status(500), ctx.json({ status: 'error' })),
+ ),
+ );
+ });
+
+ it('does not persist defaults', async () => {
+ await renderColumns();
+
+ expect(useColumnStore.getState().tables[STORAGE_KEY]).toBeUndefined();
+ expect(
+ localStorage.getItem(`@signoz/table-columns/${STORAGE_KEY}`),
+ ).toBeNull();
+ });
+
+ it('reports the column state as not persistable', async () => {
+ const { result } = await renderColumns();
+
+ expect(result.current.canPersistColumns).toBe(false);
+ });
+
+ it('ignores a selection change instead of persisting a partial set', async () => {
+ const { result } = await renderColumns();
+
+ act(() => {
+ result.current.onFieldsChange([{ name: 'trace_id' }]);
+ });
+
+ expect(useColumnStore.getState().tables[STORAGE_KEY]).toBeUndefined();
+ });
+
+ it('seeds the defaults once a later fetch succeeds', async () => {
+ const { unmount } = await renderColumns();
+ unmount();
+
+ mockAggregateKeys(AGGREGATE_KEYS);
+ const { result } = await renderColumns();
+
+ expect(result.current.canPersistColumns).toBe(true);
+ expect(fieldNames(result.current.selectedFields)).toStrictEqual([
+ 'service.name',
+ 'root_span_name',
+ 'trace_duration_nano',
+ 'span_count',
+ 'trace_id',
+ 'llm_call_count',
+ 'total_tokens',
+ 'estimated_total_cost',
+ ]);
+ });
+ });
+
it('hides the columns dropped from the selection', async () => {
const { result } = await renderColumns();
diff --git a/frontend/src/container/LLMObservability/Explorer/TracesView/configs.tsx b/frontend/src/container/LLMObservability/Explorer/TracesView/configs.tsx
index d8ee6e8dd4..fb90de5f3e 100644
--- a/frontend/src/container/LLMObservability/Explorer/TracesView/configs.tsx
+++ b/frontend/src/container/LLMObservability/Explorer/TracesView/configs.tsx
@@ -8,7 +8,7 @@ export const PER_PAGE_OPTIONS: number[] = [10, ...DEFAULT_PER_PAGE_OPTIONS];
/** Always visible: it is the row's link to the trace. */
export const TRACE_ID_COLUMN_ID = 'trace_id';
-/** Everything else starts hidden, including any aggregate the endpoint adds later. */
+/** Everything else starts hidden; only applied at first init, since the store persists hidden ids. */
const DEFAULT_VISIBLE_FIELDS = new Set([
'service.name',
'root_span_name',
diff --git a/frontend/src/container/LLMObservability/Explorer/TracesView/useTraceViewColumns.ts b/frontend/src/container/LLMObservability/Explorer/TracesView/useTraceViewColumns.ts
index 7a3ac027bc..9bc5c60738 100644
--- a/frontend/src/container/LLMObservability/Explorer/TracesView/useTraceViewColumns.ts
+++ b/frontend/src/container/LLMObservability/Explorer/TracesView/useTraceViewColumns.ts
@@ -35,11 +35,17 @@ interface UseTraceViewColumns {
onFieldsChange: (next: TelemetryFieldKey[]) => void;
requiredFields: readonly string[];
isLoading: boolean;
+ /** False until the keys fetch lands; a partial set must not reach the persisted store. */
+ canPersistColumns: boolean;
}
// TODO(ai-explorer): browser-local only, unlike the list views' `?options=` columns.
export function useTraceViewColumns(): UseTraceViewColumns {
- const { data: fetchedFields = [], isFetched } = useFieldKeysSuggestion(
+ const {
+ data: fetchedFields = [],
+ isFetched,
+ isSuccess,
+ } = useFieldKeysSuggestion(
{
...TRACE_VIEW_FIELD_KEYS,
signal: DATA_SOURCE_TO_SIGNAL[DataSource.TRACES],
@@ -60,10 +66,10 @@ export function useTraceViewColumns(): UseTraceViewColumns {
// Defaults from a partial column set would persist as the user's own choice.
useEffect(() => {
- if (isFetched) {
+ if (isSuccess) {
initializeFromDefaults(STORAGE_KEY, columns);
}
- }, [isFetched, columns]);
+ }, [isSuccess, columns]);
const hiddenColumnIds = useHiddenColumnIds(STORAGE_KEY);
const columnOrder = useColumnOrder(STORAGE_KEY);
@@ -83,6 +89,10 @@ export function useTraceViewColumns(): UseTraceViewColumns {
const onFieldsChange = useCallback(
(next: TelemetryFieldKey[]): void => {
+ if (!isSuccess) {
+ return;
+ }
+
const keptIds = new Set(next.map(columnIdOf));
columns.forEach((column) => {
@@ -96,7 +106,7 @@ export function useTraceViewColumns(): UseTraceViewColumns {
// Columns missing from the order sort last, so the visible ones suffice.
setColumnOrder(STORAGE_KEY, next.map(columnIdOf));
},
- [columns],
+ [columns, isSuccess],
);
return {
@@ -105,5 +115,6 @@ export function useTraceViewColumns(): UseTraceViewColumns {
onFieldsChange,
requiredFields: [TRACE_ID_COLUMN_ID],
isLoading: !isFetched,
+ canPersistColumns: isSuccess,
};
}
diff --git a/frontend/src/container/LLMObservability/Explorer/constants.ts b/frontend/src/container/LLMObservability/Explorer/constants.ts
index e5dcea08d5..96e0264ab1 100644
--- a/frontend/src/container/LLMObservability/Explorer/constants.ts
+++ b/frontend/src/container/LLMObservability/Explorer/constants.ts
@@ -1,7 +1,17 @@
import { TelemetrytypesFieldContextDTO } from 'api/generated/services/sigNoz.schemas';
+import { PANEL_TYPES } from 'constants/queryBuilder';
import { TelemetryFieldKey } from 'types/api/v5/queryRange';
+export const DEFAULT_PANEL_TYPE = PANEL_TYPES.TRACE;
+
export const TOOLBAR_VIEWS = {
+ trace: {
+ name: 'trace',
+ label: 'Trace',
+ disabled: false,
+ show: true,
+ key: 'trace',
+ },
list: {
name: 'list',
label: 'List',
@@ -15,13 +25,6 @@ export const TOOLBAR_VIEWS = {
show: true,
key: 'timeseries',
},
- trace: {
- name: 'trace',
- label: 'Trace',
- disabled: false,
- show: true,
- key: 'trace',
- },
table: {
name: 'table',
label: 'Table',
diff --git a/frontend/src/container/LLMObservability/Explorer/explorerUtils.ts b/frontend/src/container/LLMObservability/Explorer/explorerUtils.ts
index 9e41324913..17f224ded0 100644
--- a/frontend/src/container/LLMObservability/Explorer/explorerUtils.ts
+++ b/frontend/src/container/LLMObservability/Explorer/explorerUtils.ts
@@ -1,6 +1,5 @@
-import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
-import { OptionsQuery } from 'container/OptionsMenu/types';
-import { cloneDeep, set } from 'lodash-es';
+import { initialQueriesMap } from 'constants/queryBuilder';
+import { cloneDeep } from 'lodash-es';
import { OrderByPayload, Query } from 'types/api/queryBuilder/queryBuilderData';
export const getListViewQuery = (
@@ -31,31 +30,3 @@ export const getListViewQuery = (
return query;
};
-
-export const getQueryByPanelType = (
- stagedQuery: Query,
- panelType: PANEL_TYPES,
-): Query => {
- if (panelType === PANEL_TYPES.LIST || panelType === PANEL_TYPES.TRACE) {
- return getListViewQuery(stagedQuery);
- }
- return stagedQuery;
-};
-
-export const getExportQueryData = (
- query: Query,
- panelType: PANEL_TYPES,
- options: OptionsQuery,
-): Query => {
- if (panelType === PANEL_TYPES.LIST) {
- const updatedQuery = cloneDeep(query);
- set(
- updatedQuery,
- 'builder.queryData[0].selectColumns',
- options.selectColumns,
- );
-
- return updatedQuery;
- }
- return query;
-};
diff --git a/frontend/src/container/LLMObservability/ToolbarActions/LeftToolbarActions.tsx b/frontend/src/container/LLMObservability/ToolbarActions/LeftToolbarActions.tsx
index 8cedbda91b..9d32efafbb 100644
--- a/frontend/src/container/LLMObservability/ToolbarActions/LeftToolbarActions.tsx
+++ b/frontend/src/container/LLMObservability/ToolbarActions/LeftToolbarActions.tsx
@@ -1,19 +1,21 @@
-import {
- ArrowUpToLine,
- Atom,
- Filter,
- SquareMousePointer,
- Terminal,
- Binoculars,
-} from '@signozhq/icons';
+import { ArrowUpToLine, Filter } from '@signozhq/icons';
import { Button, Tooltip } from 'antd';
import cx from 'classnames';
import { ExplorerViews } from 'pages/LogsExplorer/utils';
+import { TOOLBAR_VIEW_CONFIG } from './toolbarViewsConfig';
+
import './ToolbarActions.styles.scss';
+interface ToolbarViewItem {
+ name: string;
+ key: string;
+ show?: boolean;
+ disabled?: boolean;
+}
+
interface LeftToolbarActionsProps {
- items: any;
+ items: Record<string, ToolbarViewItem>;
selectedView: string;
onChangeSelectedView: (view: ExplorerViews) => void;
showFilter: boolean;
@@ -29,8 +31,6 @@ export default function LeftToolbarActions({
showFilter,
handleFilterVisibilityChange,
}: LeftToolbarActionsProps): JSX.Element {
- const { clickhouse, list, timeseries, table, trace } = items;
-
return (
<div className="left-toolbar">
{!showFilter && (
@@ -41,91 +41,34 @@ export default function LeftToolbarActions({
</Button>
</Tooltip>
)}
+ {/* Buttons render in the order the caller declares its views. */}
<div className="left-toolbar-query-actions">
- {list?.show && (
- <Tooltip title="List View">
- <Button
- disabled={list.disabled}
- className={cx(
- 'list-view-tab',
- 'explorer-view-option',
- selectedView === list.key ? activeTab : '',
- )}
- onClick={(): void => onChangeSelectedView(list.key)}
- >
- <SquareMousePointer size={14} data-testid="search-view" />
- List View
- </Button>
- </Tooltip>
- )}
-
- {trace?.show && (
- <Tooltip title="Trace View">
- <Button
- disabled={trace.disabled}
- className={cx(
- 'trace-view-tab',
- 'explorer-view-option',
- selectedView === trace.key ? activeTab : '',
- )}
- onClick={(): void => onChangeSelectedView(trace.key)}
- >
- <SquareMousePointer size={14} data-testid="trace-view" />
- Trace View
- </Button>
- </Tooltip>
- )}
+ {Object.values(items).map((item) => {
+ const config = TOOLBAR_VIEW_CONFIG[item?.key];
- {timeseries?.show && (
- <Tooltip title="Time Series">
- <Button
- disabled={timeseries.disabled}
- className={cx(
- 'timeseries-view-tab',
- 'explorer-view-option',
- selectedView === timeseries.key ? activeTab : '',
- )}
- onClick={(): void => onChangeSelectedView(timeseries.key)}
- >
- <Atom size={14} data-testid="query-builder-view" />
- Time Series
- </Button>
- </Tooltip>
- )}
+ if (!item?.show || !config) {
+ return null;
+ }
- {clickhouse?.show && (
- <Tooltip title="Clickhouse">
- <Button
- disabled={clickhouse.disabled}
- className={cx(
- 'clickhouse-view-tab',
- 'explorer-view-option',
- selectedView === clickhouse.key ? activeTab : '',
- )}
- onClick={(): void => onChangeSelectedView(clickhouse.key)}
- >
- <Terminal size={14} data-testid="clickhouse-view" />
- Clickhouse
- </Button>
- </Tooltip>
- )}
+ const { icon: Icon, label, className, testId } = config;
- {table?.show && (
- <Tooltip title="Table">
- <Button
- disabled={table.disabled}
- className={cx(
- 'table-view-tab',
- 'explorer-view-option',
- selectedView === table.key ? activeTab : '',
- )}
- onClick={(): void => onChangeSelectedView(table.key)}
- >
- <Binoculars size={14} data-testid="query-builder-view-v2" />
- Table
- </Button>
- </Tooltip>
- )}
+ return (
+ <Tooltip key={item.key} title={label}>
+ <Button
+ disabled={item.disabled}
+ className={cx(
+ className,
+ 'explorer-view-option',
+ selectedView === item.key ? activeTab : '',
+ )}
+ onClick={(): void => onChangeSelectedView(item.key as ExplorerViews)}
+ >
+ <Icon size={14} data-testid={testId} />
+ {label}
+ </Button>
+ </Tooltip>
+ );
+ })}
</div>
</div>
);
diff --git a/frontend/src/container/LLMObservability/ToolbarActions/toolbarViewsConfig.ts b/frontend/src/container/LLMObservability/ToolbarActions/toolbarViewsConfig.ts
new file mode 100644
index 0000000000..f809695677
--- /dev/null
+++ b/frontend/src/container/LLMObservability/ToolbarActions/toolbarViewsConfig.ts
@@ -0,0 +1,47 @@
+import {
+ Atom,
+ Binoculars,
+ SquareMousePointer,
+ Terminal,
+} from '@signozhq/icons';
+import { ExplorerViews } from 'pages/LogsExplorer/utils';
+
+export interface ToolbarViewConfig {
+ icon: typeof Atom;
+ label: string;
+ className: string;
+ testId: string;
+}
+
+export const TOOLBAR_VIEW_CONFIG: Record<string, ToolbarViewConfig> = {
+ [ExplorerViews.LIST]: {
+ icon: SquareMousePointer,
+ label: 'List View',
+ className: 'list-view-tab',
+ testId: 'search-view',
+ },
+ [ExplorerViews.TRACE]: {
+ icon: SquareMousePointer,
+ label: 'Trace View',
+ className: 'trace-view-tab',
+ testId: 'trace-view',
+ },
+ [ExplorerViews.TIMESERIES]: {
+ icon: Atom,
+ label: 'Time Series',
+ className: 'timeseries-view-tab',
+ testId: 'query-builder-view',
+ },
+ [ExplorerViews.CLICKHOUSE]: {
+ icon: Terminal,
+ label: 'Clickhouse',
+ className: 'clickhouse-view-tab',
+ testId: 'clickhouse-view',
+ },
+ [ExplorerViews.TABLE]: {
+ icon: Binoculars,
+ label: 'Table',
+ className: 'table-view-tab',
+ testId: 'query-builder-view-v2',
+ },
+};
diff --git a/frontend/src/container/TimeSeriesView/TimeSeriesView.tsx b/frontend/src/container/TimeSeriesView/TimeSeriesView.tsx
index 4e0f201bd8..5628cb3c61 100644
--- a/frontend/src/container/TimeSeriesView/TimeSeriesView.tsx
+++ b/frontend/src/container/TimeSeriesView/TimeSeriesView.tsx
@@ -64,6 +64,7 @@ function TimeSeriesView({
panelType = PANEL_TYPES.TIME_SERIES,
stackBarChart = false,
allowExport = false,
+ exportFileName,
onYAxisUnitChange,
}: TimeSeriesViewProps): JSX.Element {
const graphRef = useRef<HTMLDivElement>(null);
@@ -270,7 +271,7 @@ function TimeSeriesView({
yAxisUnit={yAxisUnit}
data={data}
query={currentQuery}
- fileName={`${dataSource}-timeseries`}
+ fileName={exportFileName ?? `${dataSource}-timeseries`}
/>
)}
</div>
@@ -339,6 +340,7 @@ interface TimeSeriesViewProps {
stackBarChart?: boolean;
// Opt-in: render the client-side export menu (Logs explorer for now).
allowExport?: boolean;
+ exportFileName?: string;
// Opt-in: render the y-axis unit selector in the header (views without their
// own selector, e.g. Logs). Metrics keeps its separate YAxisUnitSelector.
onYAxisUnitChange?: (value: string) => void;
@@ -351,6 +353,7 @@ TimeSeriesView.defaultProps = {
setWarning: undefined,
panelType: PANEL_TYPES.TIME_SERIES,
stackBarChart: false,
+ exportFileName: undefined,
};
export default TimeSeriesView;