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.

1.1 KB
Raw Blame
import { TelemetryFieldKey } from 'api/v5/v5';
import type { TableColumnDef } from 'components/TanStackTableView/types';
import { buildCompositeKey } from 'container/OptionsMenu/utils';
import { getSpanAttribute } from 'pages/TraceDetailsV3/utils';

import { TIMESTAMP_FIELD_NAMES } from './constants';
import FieldCell from './FieldCell';

export type TracesTableRow = { id: string } & Record<string, unknown>;

export function getFieldColumn(
	field: TelemetryFieldKey,
): TableColumnDef<TracesTableRow> {
	const { name, fieldContext, fieldDataType } = field;
	const isTimestamp = TIMESTAMP_FIELD_NAMES.has(name);

	return {
		id: buildCompositeKey(name, fieldContext, fieldDataType),
		header: name,
		// Span rows nest attribute/resource fields in maps; trace rows are flat.
		accessorFn: (row): unknown =>
			row[name] ??
			getSpanAttribute(row as Parameters<typeof getSpanAttribute>[0], name),
		enableMove: !isTimestamp,
		enableRemove: !isTimestamp,
		canBeHidden: !isTimestamp,
		width: { min: 192 },
		cell: ({ value }): JSX.Element => <FieldCell name={name} value={value} />,
	};
}