import DateTime from 'sentry/components/dateTime'; import Duration from 'sentry/components/duration'; import GridEditable, {GridColumnHeader} from 'sentry/components/gridEditable'; import Link from 'sentry/components/links/link'; import {NewQuery} from 'sentry/types'; import EventView from 'sentry/utils/discover/eventView'; import {DiscoverDatasets} from 'sentry/utils/discover/types'; import {MutableSearch} from 'sentry/utils/tokenizeSearch'; import {useLocation} from 'sentry/utils/useLocation'; import {DurationComparisonCell} from 'sentry/views/starfish/components/samplesTable/common'; import useSlowMedianFastSamplesQuery from 'sentry/views/starfish/components/samplesTable/useSlowMedianFastSamplesQuery'; import { OverflowEllipsisTextContainer, TextAlignLeft, TextAlignRight, } from 'sentry/views/starfish/components/textAlign'; type Keys = 'id' | 'profile_id' | 'timestamp' | 'transaction.duration' | 'p95_comparison'; type TableColumnHeader = GridColumnHeader; const COLUMN_ORDER: TableColumnHeader[] = [ { key: 'id', name: 'Event ID', width: 140, }, { key: 'profile_id', name: 'Profile ID', width: 140, }, { key: 'timestamp', name: 'Timestamp', width: 300, }, { key: 'transaction.duration', name: 'Duration', width: 100, }, { key: 'p95_comparison', name: 'Compared to P95', width: 100, }, ]; type Props = { queryConditions: string[]; }; type DataRow = { id: string; profile_id: string; timestamp: string; 'transaction.duration': number; }; export function TransactionSamplesTable({queryConditions}: Props) { const location = useLocation(); const query = new MutableSearch(queryConditions); const savedQuery: NewQuery = { id: undefined, name: 'Endpoint Overview Samples', query: query.formatString(), projects: [1], fields: [], dataset: DiscoverDatasets.DISCOVER, version: 2, }; const eventView = EventView.fromNewQueryWithLocation(savedQuery, location); const {isLoading, data, aggregatesData} = useSlowMedianFastSamplesQuery(eventView); function renderHeadCell(column: GridColumnHeader): React.ReactNode { if (column.key === 'p95_comparison') { return ( {column.name} ); } return {column.name}; } function renderBodyCell(column: TableColumnHeader, row: DataRow): React.ReactNode { if (column.key === 'id') { return ( {row.id.slice(0, 8)} ); } if (column.key === 'profile_id') { return row.profile_id ? ( {row.profile_id.slice(0, 8)} ) : ( '(no value)' ); } if (column.key === 'transaction.duration') { return ( ); } if (column.key === 'timestamp') { return ; } if (column.key === 'p95_comparison') { return ( ); } return {row[column.key]}; } return ( ); }