Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(tracing): let people configure the span table columns (#105526)

Jimmy Zhu508f07b0945e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 68b23adacd8f..f126f349c2f5 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6868,6 +6868,14 @@ snapshots:
hash: v1.k794b7964.58421fb9485687230fc55051bb13eeefff6fec4dbc8cc0eeb9a9a9f3f39a30cd.RKEFDA_TPq6C7rBaWvs1_loggCz5bgkCHWNiGQWxX0c
products-tracing-operationstable--with-impact-columns--light:
hash: v1.k794b7964.eac04f11bc22c27252d415d04b4a1aa49fd3b8efcfc52ffee28a7e6b6e318417.A4sjcvRfFZFLstF9ShgxDiEyFTQSKg_n9y-x7DdIZpc
+ products-tracing-spancolumnconfigurator--default--dark:
+ hash: v1.k794b7964.ddb8c208195e94e8450741f84591cacdf160b9e0a4f763a9aae69989f5717328.L_CV7gZ-Yck4tTQgdgfBmzPNv_f6lcbbTQpgNT1RVfE
+ products-tracing-spancolumnconfigurator--default--light:
+ hash: v1.k794b7964.8183e665cb53bd3e71430326613bbd2cf587e162f0ad79db63ec95db8c4321c8.nZV9xPiUoxp81vFV1GmsNVBc2k-csd-A9D3Q9x-suyI
+ products-tracing-spancolumnconfigurator--open--dark:
+ hash: v1.k794b7964.8593002639416ff82ec25ffd9dbd484d6f92572ecf716dc11c4e62ddc9c6e786.A8DAKTBg4n3HzPrUJreAwiLSCnXuwYULGNxH1p9-02o
+ products-tracing-spancolumnconfigurator--open--light:
+ hash: v1.k794b7964.f470fce788f7243085e34023bfd25fb5663d0ff5ccdb4c23cf5d6f13657d9396.M5rsCUQKDv0qrlwQlMerb_pcH6fZTAQ-vULq5UIwORc
products-tracing-spanerrorsbadge--one-error--dark:
hash: v1.k794b7964.e0e79a77be55d932e351dd624093d0107d0fc1737ad2377ff59625f8c9d2919f.1kPC96NYK5FnS-qAPmFe5Vilt5aDnR_LOwvKi4SCHhw
products-tracing-spanerrorsbadge--one-error--light:
@@ -6888,6 +6896,10 @@ snapshots:
hash: v1.k794b7964.e0e79a77be55d932e351dd624093d0107d0fc1737ad2377ff59625f8c9d2919f.FoUJvZ3pT1VvRHqfLTd8ng_hDXpYvjWqiodIwsZhnGw
products-tracing-spanerrorsbadge--trace-tier-with-more-in-session--light:
hash: v1.k794b7964.b816e38267a9feb005f365b0826180703192d0d7e1775020b201aa4b9c4a1832.I52iOSlgYhkIDdh5N-Zm-Kb0yYD09_Fdkwzq1RvocwQ
+ products-tracing-virtualizedspanlist--custom-columns--dark:
+ hash: v1.k794b7964.706ec8b392aa8b7e63123ae73233f0aa49314df1f4c32894f6f48c7883c35cf3.4royX3fTwY_wCZ7DXohmhbu1njNM4B7nRI6YgxJaKiw
+ products-tracing-virtualizedspanlist--custom-columns--light:
+ hash: v1.k794b7964.ffc6e715cd33a584638b103b68ccb07b17259a87163bd9b820a145fc3ddf4f98.M1A9A8lb1VsycA0Aytgr0GEpJJL5j2fz093ClO0THKI
products-tracing-virtualizedspanlist--default--dark:
hash: v1.k794b7964.d6cf5ccbc379f67404b237b878878ce7e60512d45869c05c24dfab7784335406.zEh7cw_wZ10BGEuJkOUdjqS8SiWt7386-Cuz4Qc0Les
products-tracing-virtualizedspanlist--default--light:
@@ -6897,9 +6909,9 @@ snapshots:
products-tracing-virtualizedspanlist--empty--light:
hash: v1.k794b7964.72ff685c9162da170263d416510a2cc5229c999691288c0b8038143000a40f15.ebvPm2A_7cN8QvjEaroudYEO1lp9qFUooW98MMcDBwY
products-tracing-virtualizedspanlist--with-error-badges--dark:
- hash: v1.k794b7964.42abb3fdc9a580251a24fb411200fd29c62129989c435d24c92b88daf82b3886.bdomWMdvS-XzhaZRXAUC6CdeuNq2sAFSW9pmpYVSD7M
+ hash: v1.k794b7964.c399531ee10ef73a5ca2b732484e1eae553f40b5b95c98fc0ab0b6a5d9711188.juWZKdvphiQP-rSsWPBDvU-9cRByiTb3dLrcfV1Qh3Y
products-tracing-virtualizedspanlist--with-error-badges--light:
- hash: v1.k794b7964.15d4fc501256abd83be7a13b59db0073a1d175aeec62177d327a92024d0186d9.XHqEWOoFuCaN7-Uc2dZ5PlU9VHycCpsiv3pS6Silirw
+ hash: v1.k794b7964.7064ad6b5165631307d602ba3adcfd3fd5eb02107c8d3835c88c00df43bcad7f.3hK9J7DUCY3pFw2181ZBZbZsWlFkjm4Ydl5VNnzR5fA
products-web-analytics-content-autopilot-proposal-card--blocking-validation--dark:
hash: v1.k794b7964.8209374f939a22b6b211c2a21698ca15c4d6e18eda905eafc2c826539fa6a6f3.iZuZv-_mdz_BoFNzarvgUmumBKyNRvbdYMCWKcRQ5Bs
products-web-analytics-content-autopilot-proposal-card--blocking-validation--light:
diff --git a/products/tracing/frontend/TracingDisplayBar.tsx b/products/tracing/frontend/TracingDisplayBar.tsx
index 4e411936d4b3..c6955f123a69 100644
--- a/products/tracing/frontend/TracingDisplayBar.tsx
+++ b/products/tracing/frontend/TracingDisplayBar.tsx
@@ -10,6 +10,7 @@ import { humanFriendlyNumber } from 'lib/utils/numbers'
import { CompareMenuButton } from './components/Comparison/CompareMenuButton'
import { TracingImpactStrip } from './components/TracingImpactStrip'
+import { SpanColumnConfigurator } from './components/VirtualizedSpanList/SpanColumnConfigurator'
import { tracingConfigLogic } from './tracingConfigLogic'
import { tracingSceneLogic, type TracingDisplayMode } from './tracingSceneLogic'
@@ -18,7 +19,7 @@ import { tracingSceneLogic, type TracingDisplayMode } from './tracingSceneLogic'
*
* - left: the facet rail toggle, the row-mode selector (Traces ⇄ Spans ⇄ Operations — what
* each result row represents), and the matching-count indicator.
- * - right: Compare, hidden on the Operations view where it doesn't apply.
+ * - right: column configuration (span list only) and Compare, both hidden on Operations.
*/
export function TracingDisplayBar(): JSX.Element {
const { totalMatchingFilters, compareActive, displayMode, operationsViewEnabled } = useValues(tracingSceneLogic())
@@ -102,6 +103,9 @@ export function TracingDisplayBar(): JSX.Element {
</div>
{inTracesView && (
<div className="flex items-center gap-1.5 flex-wrap">
+ {/* A comparison replaces the span list with its own fixed table, so there are
+ no columns to configure while it is on. */}
+ {!compareActive && <SpanColumnConfigurator />}
<CompareMenuButton />
</div>
)}
diff --git a/products/tracing/frontend/TracingScene.tsx b/products/tracing/frontend/TracingScene.tsx
index 6247f65ab22d..fcd5fb7278a9 100644
--- a/products/tracing/frontend/TracingScene.tsx
+++ b/products/tracing/frontend/TracingScene.tsx
@@ -140,7 +140,7 @@ function TracingSceneContents(): JSX.Element {
selectSceneTab,
} = useActions(tracingSceneLogic())
const { addProductIntent } = useActions(teamLogic)
- const { facetRailCollapsed } = useValues(tracingConfigLogic)
+ const { facetRailCollapsed, spanColumns } = useValues(tracingConfigLogic)
const operationsViewEnabled = !!featureFlags[FEATURE_FLAGS.TRACING_OPERATIONS_VIEW]
const facetRailEnabled = !!featureFlags[FEATURE_FLAGS.TRACING_FACET_RAIL]
const heatmapEnabled = !!featureFlags[FEATURE_FLAGS.TRACING_LATENCY_HEATMAP]
@@ -300,6 +300,7 @@ function TracingSceneContents(): JSX.Element {
) : (
<VirtualizedSpanList
dataSource={listRows}
+ spanColumns={spanColumns}
loading={spansLoading}
hasMoreToLoad={hasMoreToLoad}
onLoadMore={fetchNextPage}
diff --git a/products/tracing/frontend/components/VirtualizedSpanList/SpanAttributes.tsx b/products/tracing/frontend/components/VirtualizedSpanList/SpanAttributes.tsx
index 5c5f6437cd7f..3aa8423de9ba 100644
--- a/products/tracing/frontend/components/VirtualizedSpanList/SpanAttributes.tsx
+++ b/products/tracing/frontend/components/VirtualizedSpanList/SpanAttributes.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
-import { useEffect, useRef, useState } from 'react'
+import { useEffect, useMemo, useRef, useState } from 'react'
-import { IconCheck, IconMinusSquare, IconPlusSquare } from '@posthog/icons'
+import { IconCheck, IconColumns, IconMinusSquare, IconPlusSquare } from '@posthog/icons'
import { LemonButton, LemonTable } from '@posthog/lemon-ui'
import { CopyToClipboardInline } from 'lib/components/CopyToClipboard'
@@ -17,9 +17,12 @@ import { PropertyFilterType, PropertyOperator } from '~/types'
// products resolve the same SDK-emitted attribute keys (posthogDistinctId, sessionId, ...).
import { isDistinctIdKey, isSessionIdKey } from 'products/logs/frontend/utils'
import { PersonDisplay } from 'products/persons/frontend/components/PersonDisplay'
+import { tracingConfigLogic } from 'products/tracing/frontend/tracingConfigLogic'
import { tracingCorrelationConfigLogic } from 'products/tracing/frontend/tracingCorrelationConfigLogic'
import { tracingFiltersLogic } from 'products/tracing/frontend/tracingFiltersLogic'
+import { spanColumnKey, toggleSpanAttributeColumn } from './spanColumns'
+
const APPLIED_INDICATOR_MS = 2000
// The indicator names the state the click leaves behind, not the write, because a click on a value
@@ -42,6 +45,22 @@ export interface SpanAttributesProps {
propertyType?: PropertyFilterType.SpanAttribute | PropertyFilterType.SpanResourceAttribute
}
+function ToggleColumnButton({ isColumn, onToggle }: { isColumn: boolean; onToggle: () => void }): JSX.Element {
+ return (
+ <LemonButton
+ tooltip={isColumn ? 'Remove the column for this attribute' : 'Show this attribute as a column'}
+ size="xsmall"
+ onClick={(e) => {
+ e.stopPropagation()
+ onToggle()
+ }}
+ data-attr="tracing-attribute-toggle-column"
+ >
+ <IconColumns className={isColumn ? 'text-success' : undefined} />
+ </LemonButton>
+ )
+}
+
export function SpanAttributes({
attributes,
title,
@@ -52,6 +71,9 @@ export function SpanAttributes({
const { addFilter } = useActions(tracingFiltersLogic)
const { configuredDistinctIdKeys, configuredSessionIdKeys, correlationLinksEnabled } =
useValues(tracingCorrelationConfigLogic)
+ const { spanColumns } = useValues(tracingConfigLogic)
+ const { setSpanColumns } = useActions(tracingConfigLogic)
+ const columnKeys = useMemo(() => new Set(spanColumns.map(spanColumnKey)), [spanColumns])
const [appliedFilter, setAppliedFilter] = useState<{ key: string; direction: FilterDirection } | null>(null)
const appliedFilterTimeoutRef = useRef<number | null>(null)
@@ -120,6 +142,12 @@ export function SpanAttributes({
<IconMinusSquare />
</LemonButton>
)}
+ <ToggleColumnButton
+ isColumn={columnKeys.has(
+ spanColumnKey({ type: 'attribute', attributeKey: record.key })
+ )}
+ onToggle={() => setSpanColumns(toggleSpanAttributeColumn(spanColumns, record.key))}
+ />
</div>
),
},
diff --git a/products/tracing/frontend/components/VirtualizedSpanList/SpanColumnConfigurator.stories.tsx b/products/tracing/frontend/components/VirtualizedSpanList/SpanColumnConfigurator.stories.tsx
new file mode 100644
index 000000000000..67cfbbc5fba5
--- /dev/null
+++ b/products/tracing/frontend/components/VirtualizedSpanList/SpanColumnConfigurator.stories.tsx
@@ -0,0 +1,41 @@
+import { Meta, StoryObj } from '@storybook/react'
+import { within } from '@testing-library/react'
+
+import { mswDecorator } from '~/mocks/browser'
+
+import { SpanColumnConfigurator } from './SpanColumnConfigurator'
+
+const ATTRIBUTE_KEYS = ['http.target', 'http.method', 'db.statement', 'messaging.system']
+
+const meta: Meta<typeof SpanColumnConfigurator> = {
+ title: 'Products/Tracing/SpanColumnConfigurator',
+ component: SpanColumnConfigurator,
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/tracing/spans/attributes': () => [
+ 200,
+ { results: ATTRIBUTE_KEYS.map((name) => ({ name })), count: ATTRIBUTE_KEYS.length },
+ ],
+ },
+ }),
+ ],
+ parameters: {
+ testOptions: { waitForLoadersToDisappear: false },
+ },
+}
+export default meta
+
+type Story = StoryObj<typeof SpanColumnConfigurator>
+
+export const Default: Story = {}
+
+export const Open: Story = {
+ // A native click rather than fireEvent or userEvent: both wrap the event in `act`, which throws
+ // in the production React build the visual regression runner uses.
+ play: async ({ canvasElement }) => {
+ const trigger = await within(canvasElement).findByText('Configure columns')
+ trigger.click()
+ await within(document.body).findByText('Add an attribute column')
+ },
+}
diff --git a/products/tracing/frontend/components/VirtualizedSpanList/SpanColumnConfigurator.tsx b/products/tracing/frontend/components/VirtualizedSpanList/SpanColumnConfigurator.tsx
new file mode 100644
index 000000000000..cf8a8cb27f48
--- /dev/null
+++ b/products/tracing/frontend/components/VirtualizedSpanList/SpanColumnConfigurator.tsx
@@ -0,0 +1,203 @@
+import { useActions, useValues } from 'kea'
+import { useMemo, useState } from 'react'
+
+import { IconX } from '@posthog/icons'
+import { LemonButton, LemonModal, LemonSelect } from '@posthog/lemon-ui'
+
+import { AutoSizer } from 'lib/components/AutoSizer'
+import { TaxonomicFilter } from 'lib/components/TaxonomicFilter/TaxonomicFilter'
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import { IconArrowDown, IconArrowUp, IconTuning } from 'lib/lemon-ui/icons'
+
+import { tracingConfigLogic } from '../../tracingConfigLogic'
+import {
+ addSpanColumn,
+ availableBuiltInColumns,
+ DEFAULT_SPAN_COLUMNS,
+ moveSpanColumn,
+ removeSpanColumn,
+ SpanColumnConfig,
+ spanColumnKey,
+ spanColumnLabel,
+} from './spanColumns'
+
+function DraftColumnRow({
+ column,
+ isFirst,
+ isLast,
+ onMove,
+ onRemove,
+}: {
+ column: SpanColumnConfig
+ isFirst: boolean
+ isLast: boolean
+ onMove: (direction: 'up' | 'down') => void
+ onRemove: () => void
+}): JSX.Element {
+ return (
+ <div className="flex items-center gap-1 px-2 py-1 my-1 rounded bg-accent-highlight-secondary">
+ <span className="truncate">{spanColumnLabel(column)}</span>
+ {column.type === 'attribute' && <span className="text-xs text-muted">attribute</span>}
+ <div className="flex-1" />
+ <LemonButton
+ size="small"
+ tooltip="Move up"
+ icon={<IconArrowUp />}
+ disabledReason={isFirst ? 'Already the first column' : undefined}
+ onClick={() => onMove('up')}
+ data-attr="tracing-column-move-up"
+ />
+ <LemonButton
+ size="small"
+ tooltip="Move down"
+ icon={<IconArrowDown />}
+ disabledReason={isLast ? 'Already the last column' : undefined}
+ onClick={() => onMove('down')}
+ data-attr="tracing-column-move-down"
+ />
+ <LemonButton
+ size="small"
+ status="danger"
+ tooltip="Remove"
+ icon={<IconX />}
+ onClick={onRemove}
+ data-attr="tracing-column-remove"
+ />
+ </div>
+ )
+}
+
+export function SpanColumnConfigurator(): JSX.Element {
+ const { spanColumns } = useValues(tracingConfigLogic)
+ const { setSpanColumns } = useActions(tracingConfigLogic)
+
+ const [isOpen, setIsOpen] = useState(false)
+ const [draft, setDraft] = useState<SpanColumnConfig[]>(spanColumns)
+
+ const open = (): void => {
+ setDraft(spanColumns)
+ setIsOpen(true)
+ }
+
+ const save = (): void => {
+ setSpanColumns(draft)
+ setIsOpen(false)
+ }
+
+ const builtInOptions = useMemo(
+ () => availableBuiltInColumns(draft).map((type) => ({ value: type, label: spanColumnLabel({ type }) })),
+ [draft]
+ )
+
+ return (
+ <>
+ <LemonButton
+ size="small"
+ type="secondary"
+ icon={<IconTuning />}
+ onClick={open}
+ data-attr="tracing-table-column-selector"
+ >
+ Configure columns
+ </LemonButton>
+ <LemonModal
+ isOpen={isOpen}
+ title="Configure columns"
+ onClose={() => setIsOpen(false)}
+ footer={
+ <>
+ <div className="flex-1">
+ <LemonButton type="secondary" onClick={() => setDraft(DEFAULT_SPAN_COLUMNS)}>
+ Reset to defaults
+ </LemonButton>
+ </div>
+ <LemonButton type="secondary" onClick={() => setIsOpen(false)}>
+ Close
+ </LemonButton>
+ <LemonButton
+ type="primary"
+ onClick={save}
+ disabledReason={draft.length === 0 ? 'Add at least one column' : undefined}
+ data-attr="tracing-column-apply"
+ >
+ Save
+ </LemonButton>
+ </>
+ }
+ className="w-full max-w-248"
+ >
+ <div className="flex flex-col gap-4">
+ <div className="w-full">
+ <h4 className="secondary uppercase text-secondary">Visible columns ({draft.length})</h4>
+ {draft.length === 0 ? (
+ <p className="text-muted">
+ No columns left. Add one below, or reset to the default columns.
+ </p>
+ ) : (
+ draft.map((column, index) => (
+ <DraftColumnRow
+ key={spanColumnKey(column)}
+ column={column}
+ isFirst={index === 0}
+ isLast={index === draft.length - 1}
+ onMove={(direction) =>
+ setDraft(moveSpanColumn(draft, spanColumnKey(column), direction))
+ }
+ onRemove={() => setDraft(removeSpanColumn(draft, spanColumnKey(column)))}
+ />
+ ))
+ )}
+ </div>
+ <div className="w-full">
+ <h4 className="secondary uppercase text-secondary">Add a built-in column</h4>
+ <LemonSelect
+ size="small"
+ placeholder="Pick a column"
+ disabledReason={
+ builtInOptions.length === 0 ? 'Every built-in column is already shown' : undefined
+ }
+ options={builtInOptions}
+ value={null}
+ onChange={(type) => type && setDraft(addSpanColumn(draft, { type }))}
+ data-attr="tracing-add-built-in-column"
+ />
+ </div>
+ <div className="w-full">
+ <h4 className="secondary uppercase text-secondary">Add an attribute column</h4>
+ <div className="h-[min(360px,50vh)]">
+ <AutoSizer
+ renderProp={({ height, width }) =>
+ height && width ? (
+ <TaxonomicFilter
+ height={height}
+ width={width}
+ taxonomicGroupTypes={[
+ TaxonomicFilterGroupType.SpanAttributes,
+ TaxonomicFilterGroupType.SpanResourceAttributes,
+ ]}
+ value={undefined}
+ onChange={(_group, value) => {
+ // TaxonomicFilterValue admits null, which would persist a column keyed on "null".
+ if (typeof value === 'string' && value) {
+ setDraft(
+ addSpanColumn(draft, {
+ type: 'attribute',
+ attributeKey: value,
+ })
+ )
+ }
+ }}
+ popoverEnabled={false}
+ selectFirstItem={false}
+ selectingKeyOnly
+ />
+ ) : null
+ }
+ />
+ </div>
+ </div>
+ </div>
+ </LemonModal>
+ </>
+ )
+}
diff --git a/products/tracing/frontend/components/VirtualizedSpanList/VirtualizedSpanList.stories.tsx b/products/tracing/frontend/components/VirtualizedSpanList/VirtualizedSpanList.stories.tsx
index 0b0096ca553a..da15159fb5f6 100644
--- a/products/tracing/frontend/components/VirtualizedSpanList/VirtualizedSpanList.stories.tsx
+++ b/products/tracing/frontend/components/VirtualizedSpanList/VirtualizedSpanList.stories.tsx
@@ -1,6 +1,7 @@
import { Meta, StoryObj } from '@storybook/react'
import type { Span } from '../../types'
+import { DEFAULT_SPAN_COLUMNS } from './spanColumns'
import { VirtualizedSpanList } from './VirtualizedSpanList'
const span = (index: number, overrides: Partial<Span> = {}): Span => ({
@@ -47,6 +48,7 @@ const meta: Meta<typeof VirtualizedSpanList> = {
],
args: {
dataSource: SPANS,
+ spanColumns: DEFAULT_SPAN_COLUMNS,
loading: false,
orderBy: 'timestamp',
orderDirection: 'DESC',
@@ -78,3 +80,18 @@ export const WithErrorBadges: Story = {
},
},
}
+
+export const CustomColumns: Story = {
+ args: {
+ dataSource: SPANS.map((span, index) => ({
+ ...span,
+ attributes: { 'http.target': index % 2 === 0 ? '/api/v2/checkout/session/confirm' : '' },
+ })),
+ spanColumns: [
+ { type: 'timestamp' },
+ { type: 'name' },
+ { type: 'attribute', attributeKey: 'http.target' },
+ { type: 'duration' },
+ ],
+ },
+}
diff --git a/products/tracing/frontend/components/VirtualizedSpanList/VirtualizedSpanList.tsx b/products/tracing/frontend/components/VirtualizedSpanList/VirtualizedSpanList.tsx
index 8b1a843e98d6..104addd5b640 100644
--- a/products/tracing/frontend/components/VirtualizedSpanList/VirtualizedSpanList.tsx
+++ b/products/tracing/frontend/components/VirtualizedSpanList/VirtualizedSpanList.tsx
@@ -1,4 +1,4 @@
-import { CSSProperties, ReactNode, useCallback, useRef } from 'react'
+import { CSSProperties, ReactNode, useCallback, useMemo, useRef } from 'react'
import { List, useListRef } from 'react-window'
import { LemonTag } from '@posthog/lemon-ui'
@@ -16,10 +16,17 @@ import { formatDuration } from '../../TraceWaterfallView'
import type { TracingOrderBy, TracingOrderDirection } from '../../tracingFiltersLogic'
import { SPAN_KIND_LABELS, STATUS_CODE_LABELS } from '../../types'
import type { Span } from '../../types'
-import { MIN_COLUMN_WIDTH, ResizableColumnSpec } from '../TableColumns/columnWidths'
import { TableCell } from '../TableColumns/TableCell'
import { TableHeaderCell } from '../TableColumns/TableHeaderCell'
import { ResizableColumns, useResizableColumns } from '../TableColumns/useResizableColumns'
+import {
+ SpanColumnConfig,
+ spanAttributeValue,
+ spanColumnKey,
+ spanColumnLabel,
+ spanColumnSortKey,
+ toSpanColumnSpecs,
+} from './spanColumns'
import { SpanErrorsBadge } from './SpanErrorsBadge'
import { SpanRowActions } from './SpanRowActions'
@@ -28,21 +35,6 @@ const HEADER_HEIGHT = 32
// Trigger the next page once the bottom of the rendered window is within this many rows of the end.
const LOAD_MORE_THRESHOLD = 10
-// Default column widths (px), in render order. Anyone can drag a column wider or narrower from here.
-const SPAN_COLUMNS: ResizableColumnSpec[] = [
- { key: 'timestamp', width: 215 },
- { key: 'name', width: 320, grow: true },
- { key: 'service', width: 200 },
- { key: 'kind', width: 90 },
- { key: 'duration', width: 90 },
- { key: 'status', width: 80 },
- // The error badge. It holds its width on rows with no errors so the columns beside it stay
- // aligned down the page as counts arrive.
- { key: 'spanErrors', width: MIN_COLUMN_WIDTH },
- { key: 'traceId', width: 140 },
- { key: 'actions', width: 130 },
-]
-const SPAN_COLUMNS_WITHOUT_ERRORS: ResizableColumnSpec[] = SPAN_COLUMNS.filter((column) => column.key !== 'spanErrors')
// pinned: identifies stored column widths — renaming resets everyone's widths
const TABLE_KEY = 'spans'
@@ -73,10 +65,12 @@ interface VirtualizedSpanListProps extends SortProps {
onLoadMore?: () => void
emptyState?: ReactNode
spanErrors?: SpanErrors
+ spanColumns: SpanColumnConfig[]
}
interface SpanRowProps {
dataSource: Span[]
+ spanColumns: SpanColumnConfig[]
widths: Record<string, number>
onRowClick: (span: Span) => void
spanErrors: SpanErrors | undefined
@@ -126,6 +120,7 @@ function SpanHeaderCell({
}
function SpanRowHeader({
+ spanColumns,
widths,
columns,
showSpanErrors,
@@ -133,6 +128,7 @@ function SpanRowHeader({
orderDirection,
onSort,
}: {
+ spanColumns: SpanColumnConfig[]
widths: Record<string, number>
columns: ResizableColumns
showSpanErrors: boolean
@@ -145,43 +141,92 @@ function SpanRowHeader({
// eslint-disable-next-line react/forbid-dom-props
style={{ height: HEADER_HEIGHT }}
>
- <SpanHeaderCell
- {...shared}
- columnKey="timestamp"
- label="Timestamp"
- sort={{ column: 'timestamp', ...sortProps }}
- />
- <SpanHeaderCell {...shared} columnKey="name" label="Name" />
- <SpanHeaderCell {...shared} columnKey="service" label="Service" />
- <SpanHeaderCell {...shared} columnKey="kind" label="Kind" />
- <SpanHeaderCell
- {...shared}
- columnKey="duration"
- label="Duration"
- sort={{ column: 'duration', ...sortProps }}
- />
- <SpanHeaderCell {...shared} columnKey="status" label="Status" />
+ {spanColumns.map((column) => {
+ const sortKey = spanColumnSortKey(column)
+ const key = spanColumnKey(column)
+ return (
+ <SpanHeaderCell
+ key={key}
+ {...shared}
+ columnKey={key}
+ label={spanColumnLabel(column)}
+ sort={sortKey ? { column: sortKey, ...sortProps } : undefined}
+ />
+ )
+ })}
{/* The error badge needs no heading; its tooltip says what the count means. */}
{showSpanErrors && <SpanHeaderCell {...shared} columnKey="spanErrors" resizeLabel="Errors" />}
- <SpanHeaderCell {...shared} columnKey="traceId" label="Trace ID" />
{/* Row actions need no heading. */}
<SpanHeaderCell {...shared} columnKey="actions" />
</div>
)
}
+function spanCellContent(column: SpanColumnConfig, span: Span): JSX.Element | null {
+ switch (column.type) {
+ case 'timestamp':
+ return (
+ <span className="font-mono">
+ <TZLabel
+ time={span.timestamp}
+ formatDate={TRACING_DATE_FORMAT}
+ formatTime={TRACING_TIME_FORMAT}
+ displayTimezone={TRACING_DISPLAY_TIMEZONE}
+ showSeconds
+ />
+ </span>
+ )
+ case 'name':
+ return (
+ <span className="flex items-center gap-2 truncate">
+ <span className="truncate">{span.name}</span>
+ {isRootSpan(span) && (
+ <LemonTag type="highlight" size="small">
+ trace
+ </LemonTag>
+ )}
+ </span>
+ )
+ case 'service':
+ return <LemonTag>{span.service_name}</LemonTag>
+ case 'kind':
+ return <>{SPAN_KIND_LABELS[span.kind] ?? span.kind}</>
+ case 'duration':
+ return <>{formatDuration(span.duration_nano)}</>
+ case 'status': {
+ const status = STATUS_CODE_LABELS[span.status_code] ?? {
+ label: String(span.status_code),
+ type: 'default' as const,
+ }
+ return <LemonTag type={status.type}>{status.label}</LemonTag>
+ }
+ case 'traceId':
+ return <span className="font-mono">{span.trace_id.substring(0, 16)}...</span>
+ case 'attribute': {
+ const value = spanAttributeValue(span, column.attributeKey)
+ // Empty rather than a placeholder, so a column added for one service is not noise on the rest.
+ return value ? (
+ <span className="font-mono" title={value}>
+ {value}
+ </span>
+ ) : null
+ }
+ }
+}
+
function SpanRow({
span,
+ spanColumns,
widths,
spanErrors,
onClick,
}: {
span: Span
+ spanColumns: SpanColumnConfig[]
widths: Record<string, number>
spanErrors: SpanErrors | undefined
onClick: () => void
}): JSX.Element {
- const status = STATUS_CODE_LABELS[span.status_code] ?? { label: String(span.status_code), type: 'default' as const }
const errorBadge = spanErrors?.badges.get(span.uuid)
return (
@@ -201,35 +246,14 @@ function SpanRow({
role="button"
tabIndex={0}
>
- <TableCell width={widths.timestamp}>
- <span className="font-mono">
- <TZLabel
- time={span.timestamp}
- formatDate={TRACING_DATE_FORMAT}
- formatTime={TRACING_TIME_FORMAT}
- displayTimezone={TRACING_DISPLAY_TIMEZONE}
- showSeconds
- />
- </span>
- </TableCell>
- <TableCell width={widths.name}>
- <span className="flex items-center gap-2 truncate">
- <span className="truncate">{span.name}</span>
- {isRootSpan(span) && (
- <LemonTag type="highlight" size="small">
- trace
- </LemonTag>
- )}
- </span>
- </TableCell>
- <TableCell width={widths.service}>
- <LemonTag>{span.service_name}</LemonTag>
- </TableCell>
- <TableCell width={widths.kind}>{SPAN_KIND_LABELS[span.kind] ?? span.kind}</TableCell>
- <TableCell width={widths.duration}>{formatDuration(span.duration_nano)}</TableCell>
- <TableCell width={widths.status}>
- <LemonTag type={status.type}>{status.label}</LemonTag>
- </TableCell>
+ {spanColumns.map((column) => {
+ const key = spanColumnKey(column)
+ return (
+ <TableCell key={key} width={widths[key]}>
+ {spanCellContent(column, span)}
+ </TableCell>
+ )
+ })}
{spanErrors && (
<TableCell width={widths.spanErrors}>
{errorBadge && (
@@ -242,9 +266,6 @@ function SpanRow({
)}
</TableCell>
)}
- <TableCell width={widths.traceId}>
- <span className="font-mono">{span.trace_id.substring(0, 16)}...</span>
- </TableCell>
<TableCell width={widths.actions}>
<SpanRowActions span={span} onViewTrace={onClick} />
</TableCell>
@@ -257,6 +278,7 @@ function SpanListRow({
index,
style,
dataSource,
+ spanColumns,
widths,
spanErrors,
onRowClick,
@@ -270,7 +292,13 @@ function SpanListRow({
return (
// eslint-disable-next-line react/forbid-dom-props
<div {...ariaAttributes} style={style} data-index={index} data-row-key={span.uuid}>
- <SpanRow span={span} widths={widths} spanErrors={spanErrors} onClick={() => onRowClick(span)} />
+ <SpanRow
+ span={span}
+ spanColumns={spanColumns}
+ widths={widths}
+ spanErrors={spanErrors}
+ onClick={() => onRowClick(span)}
+ />
</div>
)
}
@@ -284,6 +312,7 @@ export function VirtualizedSpanList({
onLoadMore,
emptyState = 'No spans found',
spanErrors,
+ spanColumns,
orderBy,
orderDirection,
onSort,
@@ -292,10 +321,11 @@ export function VirtualizedSpanList({
const lastVisibleRangeRef = useRef<{ startIndex: number; stopIndex: number } | null>(null)
const listRef = useListRef(null)
- // Both variants are module constants, because useResizableColumns reuses its resolved widths
- // object while the specs identity holds. Building the array here would hand every virtualized
- // row new widths on every render.
- const columns = useResizableColumns(TABLE_KEY, spanErrors ? SPAN_COLUMNS : SPAN_COLUMNS_WITHOUT_ERRORS)
+ // The dependency is the boolean, not `spanErrors`: that object gets a new identity every time
+ // error counts arrive, which would break the specs identity useResizableColumns caches on.
+ const showSpanErrors = !!spanErrors
+ const specs = useMemo(() => toSpanColumnSpecs(spanColumns, { showSpanErrors }), [spanColumns, showSpanErrors])
+ const columns = useResizableColumns(TABLE_KEY, specs)
const handleRowsRendered = useCallback(
(
@@ -348,9 +378,10 @@ export function VirtualizedSpanList({
{/* eslint-disable-next-line react/forbid-dom-props */}
<div style={{ width: rowWidth }}>
<SpanRowHeader
+ spanColumns={spanColumns}
widths={widths}
columns={columns}
- showSpanErrors={!!spanErrors}
+ showSpanErrors={showSpanErrors}
orderBy={orderBy}
orderDirection={orderDirection}
onSort={onSort}
@@ -361,7 +392,7 @@ export function VirtualizedSpanList({
rowCount={dataSource.length}
rowHeight={ROW_HEIGHT}
rowComponent={SpanListRow}
- rowProps={{ dataSource, widths, spanErrors, onRowClick }}
+ rowProps={{ dataSource, spanColumns, widths, spanErrors, onRowClick }}
onRowsRendered={handleRowsRendered}
listRef={listRef}
/>
diff --git a/products/tracing/frontend/components/VirtualizedSpanList/spanColumns.test.ts b/products/tracing/frontend/components/VirtualizedSpanList/spanColumns.test.ts
new file mode 100644
index 000000000000..2f98f4353384
--- /dev/null
+++ b/products/tracing/frontend/components/VirtualizedSpanList/spanColumns.test.ts
@@ -0,0 +1,101 @@
+import type { Span } from '../../types'
+import {
+ addSpanColumn,
+ availableBuiltInColumns,
+ DEFAULT_SPAN_COLUMNS,
+ moveSpanColumn,
+ normalizeSpanColumns,
+ removeSpanColumn,
+ SpanColumnConfig,
+ spanAttributeValue,
+ spanColumnKey,
+ toggleSpanAttributeColumn,
+ toSpanColumnSpecs,
+} from './spanColumns'
+
+describe('spanColumns', () => {
+ const attributeColumn: SpanColumnConfig = { type: 'attribute', attributeKey: 'http.target' }
+
+ const span = (overrides: Partial<Span>): Span => ({ attributes: {}, resource_attributes: {}, ...overrides }) as Span
+
+ it('keeps an attribute column distinct from a built-in of the same name', () => {
+ expect(spanColumnKey({ type: 'attribute', attributeKey: 'name' })).not.toEqual(spanColumnKey({ type: 'name' }))
+ })
+
+ it('reads an attribute from the span first, then the resource', () => {
+ const key = 'service.version'
+ expect(spanAttributeValue(span({ attributes: { [key]: '2.1' } }), key)).toEqual('2.1')
+ expect(spanAttributeValue(span({ resource_attributes: { [key]: '1.0' } }), key)).toEqual('1.0')
+ expect(
+ spanAttributeValue(span({ attributes: { [key]: '2.1' }, resource_attributes: { [key]: '1.0' } }), key)
+ ).toEqual('2.1')
+ expect(spanAttributeValue(span({}), key)).toEqual('')
+ })
+
+ it('does not add a column the table already shows', () => {
+ const columns = addSpanColumn(DEFAULT_SPAN_COLUMNS, { type: 'name' })
+ expect(columns).toEqual(DEFAULT_SPAN_COLUMNS)
+ })
+
+ it('offers only the built-in columns that are not on screen', () => {
+ expect(availableBuiltInColumns(DEFAULT_SPAN_COLUMNS)).toEqual([])
+ expect(availableBuiltInColumns(removeSpanColumn(DEFAULT_SPAN_COLUMNS, 'kind'))).toEqual(['kind'])
+ })
+
+ it('adds an attribute column on the first toggle and removes it on the second', () => {
+ const added = toggleSpanAttributeColumn(DEFAULT_SPAN_COLUMNS, 'http.target')
+ expect(added).toContainEqual(attributeColumn)
+ expect(toggleSpanAttributeColumn(added, 'http.target')).toEqual(DEFAULT_SPAN_COLUMNS)
+ })
+
+ it.each([
+ ['up', 'timestamp', ['timestamp', 'name']],
+ ['down', 'name', ['timestamp', 'name']],
+ ] as const)('leaves the list untouched moving %s past the end', (direction, key, expected) => {
+ const columns: SpanColumnConfig[] = [{ type: 'timestamp' }, { type: 'name' }]
+ expect(moveSpanColumn(columns, key, direction).map(spanColumnKey)).toEqual(expected)
+ })
+
+ it('moves a column one place', () => {
+ const columns: SpanColumnConfig[] = [{ type: 'timestamp' }, { type: 'name' }, attributeColumn]
+ expect(moveSpanColumn(columns, 'attr:http.target', 'up').map(spanColumnKey)).toEqual([
+ 'timestamp',
+ 'attr:http.target',
+ 'name',
+ ])
+ })
+
+ it.each([
+ ['a type this version cannot render', [{ type: 'timestamp' }, { type: 'retiredColumn' }], ['timestamp']],
+ ['an attribute column with no key', [{ type: 'timestamp' }, { type: 'attribute' }], ['timestamp']],
+ ['a duplicate', [{ type: 'timestamp' }, { type: 'timestamp' }], ['timestamp']],
+ ['a non-object entry', [{ type: 'timestamp' }, null, 'timestamp'], ['timestamp']],
+ ])('drops %s from persisted columns', (_case, stored, expected) => {
+ expect(normalizeSpanColumns(stored).map(spanColumnKey)).toEqual(expected)
+ })
+
+ it.each([
+ ['nothing persisted', undefined],
+ ['a value that is not a list', { type: 'timestamp' }],
+ ['a list with nothing renderable left', [{ type: 'retiredColumn' }]],
+ ])('falls back to the default columns for %s', (_case, stored) => {
+ expect(normalizeSpanColumns(stored)).toEqual(DEFAULT_SPAN_COLUMNS)
+ })
+
+ it('appends the structural columns after the configured ones', () => {
+ const specs = toSpanColumnSpecs([{ type: 'timestamp' }], { showSpanErrors: true })
+ expect(specs.map((spec) => spec.key)).toEqual(['timestamp', 'spanErrors', 'actions'])
+ expect(toSpanColumnSpecs([{ type: 'timestamp' }], { showSpanErrors: false }).map((spec) => spec.key)).toEqual([
+ 'timestamp',
+ 'actions',
+ ])
+ })
+
+ it('grows the last configured column when name is not on screen, so the table still fills the viewport', () => {
+ const withName = toSpanColumnSpecs(DEFAULT_SPAN_COLUMNS, { showSpanErrors: false })
+ expect(withName.find((spec) => spec.grow)?.key).toEqual('name')
+
+ const withoutName = toSpanColumnSpecs([{ type: 'timestamp' }, attributeColumn], { showSpanErrors: false })
+ expect(withoutName.find((spec) => spec.grow)?.key).toEqual('attr:http.target')
+ })
+})
diff --git a/products/tracing/frontend/components/VirtualizedSpanList/spanColumns.ts b/products/tracing/frontend/components/VirtualizedSpanList/spanColumns.ts
new file mode 100644
index 000000000000..415d2fd8d1d8
--- /dev/null
+++ b/products/tracing/frontend/components/VirtualizedSpanList/spanColumns.ts
@@ -0,0 +1,137 @@
+import type { TracingOrderBy } from '../../tracingFiltersLogic'
+import type { Span } from '../../types'
+import { MIN_COLUMN_WIDTH, ResizableColumnSpec } from '../TableColumns/columnWidths'
+
+export type BuiltInSpanColumnType = 'timestamp' | 'name' | 'service' | 'kind' | 'duration' | 'status' | 'traceId'
+
+export type SpanColumnConfig = { type: BuiltInSpanColumnType } | { type: 'attribute'; attributeKey: string }
+
+export type SpanColumnType = SpanColumnConfig['type']
+
+interface BuiltInSpanColumn {
+ label: string
+ width: number
+ sortKey?: TracingOrderBy
+}
+
+// pinned: these keys are also the stored-width keys, so a rename resets everyone's widths.
+export const SPAN_COLUMN_REGISTRY: Record<BuiltInSpanColumnType, BuiltInSpanColumn> = {
+ timestamp: { label: 'Timestamp', width: 215, sortKey: 'timestamp' },
+ name: { label: 'Name', width: 320 },
+ service: { label: 'Service', width: 200 },
+ kind: { label: 'Kind', width: 90 },
+ duration: { label: 'Duration', width: 90, sortKey: 'duration' },
+ status: { label: 'Status', width: 80 },
+ traceId: { label: 'Trace ID', width: 140 },
+}
+
+export const DEFAULT_ATTRIBUTE_COLUMN_WIDTH = 200
+
+export const DEFAULT_SPAN_COLUMNS: SpanColumnConfig[] = [
+ { type: 'timestamp' },
+ { type: 'name' },
+ { type: 'service' },
+ { type: 'kind' },
+ { type: 'duration' },
+ { type: 'status' },
+ { type: 'traceId' },
+]
+
+/** The prefix keeps an attribute named `name` from colliding with the built-in `name` column. */
+export function spanColumnKey(column: SpanColumnConfig): string {
+ return column.type === 'attribute' ? `attr:${column.attributeKey}` : column.type
+}
+
+export function spanColumnLabel(column: SpanColumnConfig): string {
+ return column.type === 'attribute' ? column.attributeKey : SPAN_COLUMN_REGISTRY[column.type].label
+}
+
+export function spanColumnSortKey(column: SpanColumnConfig): TracingOrderBy | undefined {
+ return column.type === 'attribute' ? undefined : SPAN_COLUMN_REGISTRY[column.type].sortKey
+}
+
+export function spanAttributeValue(span: Span, attributeKey: string): string {
+ return span.attributes?.[attributeKey] ?? span.resource_attributes?.[attributeKey] ?? ''
+}
+
+export function availableBuiltInColumns(columns: SpanColumnConfig[]): BuiltInSpanColumnType[] {
+ const present = new Set(columns.map(spanColumnKey))
+ return (Object.keys(SPAN_COLUMN_REGISTRY) as BuiltInSpanColumnType[]).filter((type) => !present.has(type))
+}
+
+export function addSpanColumn(columns: SpanColumnConfig[], column: SpanColumnConfig): SpanColumnConfig[] {
+ const key = spanColumnKey(column)
+ return columns.some((existing) => spanColumnKey(existing) === key) ? columns : [...columns, column]
+}
+
+export function removeSpanColumn(columns: SpanColumnConfig[], key: string): SpanColumnConfig[] {
+ return columns.filter((column) => spanColumnKey(column) !== key)
+}
+
+export function moveSpanColumn(columns: SpanColumnConfig[], key: string, direction: 'up' | 'down'): SpanColumnConfig[] {
+ const index = columns.findIndex((column) => spanColumnKey(column) === key)
+ const target = direction === 'up' ? index - 1 : index + 1
+ if (index === -1 || target < 0 || target >= columns.length) {
+ return columns
+ }
+ const next = [...columns]
+ ;[next[index], next[target]] = [next[target], next[index]]
+ return next
+}
+
+export function toggleSpanAttributeColumn(columns: SpanColumnConfig[], attributeKey: string): SpanColumnConfig[] {
+ const key = spanColumnKey({ type: 'attribute', attributeKey })
+ return columns.some((column) => spanColumnKey(column) === key)
+ ? removeSpanColumn(columns, key)
+ : addSpanColumn(columns, { type: 'attribute', attributeKey })
+}
+
+/** Filters what an older version persisted, so editing the registry cannot throw on load. */
+export function normalizeSpanColumns(stored: unknown): SpanColumnConfig[] {
+ if (!Array.isArray(stored)) {
+ return DEFAULT_SPAN_COLUMNS
+ }
+ const normalized = stored.reduce<SpanColumnConfig[]>((columns, entry) => {
+ if (!entry || typeof entry !== 'object') {
+ return columns
+ }
+ const { type, attributeKey } = entry as { type?: unknown; attributeKey?: unknown }
+ if (type === 'attribute') {
+ return typeof attributeKey === 'string' && attributeKey
+ ? addSpanColumn(columns, { type, attributeKey })
+ : columns
+ }
+ return typeof type === 'string' && type in SPAN_COLUMN_REGISTRY
+ ? addSpanColumn(columns, { type: type as BuiltInSpanColumnType })
+ : columns
+ }, [])
+ return normalized.length > 0 ? normalized : DEFAULT_SPAN_COLUMNS
+}
+
+/** The error badge is not configurable, because its flagged feature owns whether it renders. */
+export function toSpanColumnSpecs(
+ columns: SpanColumnConfig[],
+ { showSpanErrors }: { showSpanErrors: boolean }
+): ResizableColumnSpec[] {
+ // Without a growing column the table stops filling the viewport, so the last one takes over.
+ const growColumn = columns.find((column) => column.type === 'name') ?? columns[columns.length - 1]
+ const growKey = growColumn && spanColumnKey(growColumn)
+
+ const specs: ResizableColumnSpec[] = columns.map((column) => {
+ const key = spanColumnKey(column)
+ return {
+ key,
+ width:
+ column.type === 'attribute' ? DEFAULT_ATTRIBUTE_COLUMN_WIDTH : SPAN_COLUMN_REGISTRY[column.type].width,
+ grow: key === growKey || undefined,
+ }
+ })
+
+ if (showSpanErrors) {
+ // The error badge holds its width on rows with no errors so the columns beside it stay
+ // aligned down the page as counts arrive.
+ specs.push({ key: 'spanErrors', width: MIN_COLUMN_WIDTH })
+ }
+ specs.push({ key: 'actions', width: 130 })
+ return specs
+}
diff --git a/products/tracing/frontend/tracingConfigLogic.ts b/products/tracing/frontend/tracingConfigLogic.ts
index 38a052931cd2..7eaf4a3f31d3 100644
--- a/products/tracing/frontend/tracingConfigLogic.ts
+++ b/products/tracing/frontend/tracingConfigLogic.ts
@@ -1,4 +1,10 @@
-import { MakeLogicType, actions, kea, path, reducers } from 'kea'
+import { MakeLogicType, actions, kea, path, reducers, selectors } from 'kea'
+
+import {
+ DEFAULT_SPAN_COLUMNS,
+ normalizeSpanColumns,
+ SpanColumnConfig,
+} from './components/VirtualizedSpanList/spanColumns'
/** Column widths a person has dragged, keyed by table then column. */
export type TracingColumnWidths = Record<string, Record<string, number>>
@@ -7,6 +13,8 @@ export type TracingColumnWidths = Record<string, Record<string, number>>
export interface tracingConfigLogicValues {
columnWidths: TracingColumnWidths
facetRailCollapsed: boolean
+ spanColumns: SpanColumnConfig[]
+ storedSpanColumns: SpanColumnConfig[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -30,9 +38,24 @@ export interface tracingConfigLogicActions {
setFacetRailCollapsed: (facetRailCollapsed: boolean) => {
facetRailCollapsed: boolean
}
+ setSpanColumns: (columns: SpanColumnConfig[]) => {
+ columns: SpanColumnConfig[]
+ }
}
-export type tracingConfigLogicType = MakeLogicType<tracingConfigLogicValues, tracingConfigLogicActions>
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface tracingConfigLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ spanColumns: (storedSpanColumns: SpanColumnConfig[]) => SpanColumnConfig[]
+ }
+}
+
+export type tracingConfigLogicType = MakeLogicType<
+ tracingConfigLogicValues,
+ tracingConfigLogicActions,
+ Record<string, any>,
+ tracingConfigLogicMeta
+>
/** Display-only preferences for the tracing scene — never affects the query. */
export const tracingConfigLogic = kea<tracingConfigLogicType>([
@@ -42,6 +65,7 @@ export const tracingConfigLogic = kea<tracingConfigLogicType>([
setFacetRailCollapsed: (facetRailCollapsed: boolean) => ({ facetRailCollapsed }),
setColumnWidth: (tableKey: string, columnKey: string, width: number) => ({ tableKey, columnKey, width }),
resetColumnWidth: (tableKey: string, columnKey: string) => ({ tableKey, columnKey }),
+ setSpanColumns: (columns: SpanColumnConfig[]) => ({ columns }),
}),
reducers({
@@ -52,6 +76,13 @@ export const tracingConfigLogic = kea<tracingConfigLogicType>([
setFacetRailCollapsed: (_, { facetRailCollapsed }) => facetRailCollapsed,
},
],
+ storedSpanColumns: [
+ DEFAULT_SPAN_COLUMNS,
+ { persist: true },
+ {
+ setSpanColumns: (_, { columns }) => columns,
+ },
+ ],
columnWidths: [
{} as TracingColumnWidths,
{ persist: true },
@@ -67,4 +98,14 @@ export const tracingConfigLogic = kea<tracingConfigLogicType>([
},
],
}),
+
+ selectors({
+ // Filtered on the way out, because the persisted value outlives the code that wrote it.
+ spanColumns: [
+ (s) => [s.storedSpanColumns],
+ // Inline with an explicit return type, because kea-typegen cannot infer the value type
+ // from a bare function reference and drops the selector from the values interface.
+ (storedSpanColumns: SpanColumnConfig[]): SpanColumnConfig[] => normalizeSpanColumns(storedSpanColumns),
+ ],
+ }),
])