From 911efe336acf58bcc8ae9b39d13806a63b642236 Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Fri, 22 Nov 2024 13:24:51 -0500 Subject: [PATCH] feat(explore): Ensure id column is present in samples mode It's possible for users to remove the id column in the column editor. But if they do so, the result isn't very useful since it won't link to a trace. So we ensure the id column is always present no matter what columns are selected. --- static/app/views/explore/tables/spansTable.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/static/app/views/explore/tables/spansTable.tsx b/static/app/views/explore/tables/spansTable.tsx index cbf4274f3902e1..8637d05976229d 100644 --- a/static/app/views/explore/tables/spansTable.tsx +++ b/static/app/views/explore/tables/spansTable.tsx @@ -103,8 +103,13 @@ export function SpansTable({setError}: SpansTableProps) { userQuery: query, }); + const visibleFields = useMemo( + () => (fields.includes('id') ? fields : ['id', ...fields]), + [fields] + ); + const {tableStyles} = useTableStyles({ - items: fields.map(field => { + items: visibleFields.map(field => { return { label: field, value: field, @@ -122,7 +127,7 @@ export function SpansTable({setError}: SpansTableProps) { - {fields.map((field, i) => { + {visibleFields.map((field, i) => { // Hide column names before alignment is determined if (result.isPending) { return ; @@ -176,7 +181,7 @@ export function SpansTable({setError}: SpansTableProps) { ) : result.isFetched && result.data?.length ? ( result.data?.map((row, i) => ( - {fields.map((field, j) => { + {visibleFields.map((field, j) => { return (