2023-02-03 18:06:26 +05:30
|
|
|
import { Tooltip, Typography } from 'antd';
|
2021-10-20 09:24:55 +05:30
|
|
|
import { ColumnsType } from 'antd/lib/table';
|
2023-02-03 18:06:26 +05:30
|
|
|
import { ResizeTable } from 'components/ResizeTable';
|
2023-03-29 14:45:58 +05:30
|
|
|
import useResourceAttribute from 'hooks/useResourceAttribute';
|
|
|
|
|
import { convertRawQueriesToTraceSelectedTags } from 'hooks/useResourceAttribute/utils';
|
2021-11-16 21:13:20 +05:30
|
|
|
import { useSelector } from 'react-redux';
|
2022-03-22 21:56:12 +05:30
|
|
|
import { useParams } from 'react-router-dom';
|
2021-10-20 09:24:55 +05:30
|
|
|
import { AppState } from 'store/reducers';
|
|
|
|
|
import { GlobalReducer } from 'types/reducer/globalTime';
|
|
|
|
|
|
2023-07-28 21:54:36 +05:30
|
|
|
import { getErrorRate, navigateToTrace } from './utils';
|
2023-06-12 18:19:07 +05:30
|
|
|
|
2023-10-08 23:21:17 +05:30
|
|
|
function TopOperationsTable({ data }: TopOperationsTableProps): JSX.Element {
|
2021-10-20 09:24:55 +05:30
|
|
|
const { minTime, maxTime } = useSelector<AppState, GlobalReducer>(
|
|
|
|
|
(state) => state.globalTime,
|
|
|
|
|
);
|
2023-03-29 14:45:58 +05:30
|
|
|
const { queries } = useResourceAttribute();
|
2022-05-03 15:41:40 +05:30
|
|
|
|
|
|
|
|
const selectedTraceTags: string = JSON.stringify(
|
2023-03-29 14:45:58 +05:30
|
|
|
convertRawQueriesToTraceSelectedTags(queries) || [],
|
2022-05-03 15:41:40 +05:30
|
|
|
);
|
2021-10-20 09:24:55 +05:30
|
|
|
|
|
|
|
|
const params = useParams<{ servicename: string }>();
|
|
|
|
|
|
|
|
|
|
const handleOnClick = (operation: string): void => {
|
|
|
|
|
const { servicename } = params;
|
|
|
|
|
|
2023-07-28 21:54:36 +05:30
|
|
|
navigateToTrace({
|
|
|
|
|
servicename,
|
|
|
|
|
operation,
|
|
|
|
|
minTime,
|
|
|
|
|
maxTime,
|
|
|
|
|
selectedTraceTags,
|
|
|
|
|
});
|
2021-10-20 09:24:55 +05:30
|
|
|
};
|
|
|
|
|
|
2023-04-27 17:17:15 +05:30
|
|
|
const columns: ColumnsType<TopOperationList> = [
|
2021-10-20 09:24:55 +05:30
|
|
|
{
|
|
|
|
|
title: 'Name',
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
key: 'name',
|
2023-02-02 16:53:15 +05:30
|
|
|
width: 100,
|
2021-10-20 09:24:55 +05:30
|
|
|
render: (text: string): JSX.Element => (
|
|
|
|
|
<Tooltip placement="topLeft" title={text}>
|
2022-05-18 22:22:12 +05:30
|
|
|
<Typography.Link onClick={(): void => handleOnClick(text)}>
|
2021-10-20 09:24:55 +05:30
|
|
|
{text}
|
2022-05-18 22:22:12 +05:30
|
|
|
</Typography.Link>
|
2021-10-20 09:24:55 +05:30
|
|
|
</Tooltip>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'P50 (in ms)',
|
|
|
|
|
dataIndex: 'p50',
|
|
|
|
|
key: 'p50',
|
2023-02-02 16:53:15 +05:30
|
|
|
width: 50,
|
2023-04-27 17:17:15 +05:30
|
|
|
sorter: (a: TopOperationList, b: TopOperationList): number => a.p50 - b.p50,
|
2021-10-20 09:24:55 +05:30
|
|
|
render: (value: number): string => (value / 1000000).toFixed(2),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'P95 (in ms)',
|
|
|
|
|
dataIndex: 'p95',
|
|
|
|
|
key: 'p95',
|
2023-02-02 16:53:15 +05:30
|
|
|
width: 50,
|
2023-04-27 17:17:15 +05:30
|
|
|
sorter: (a: TopOperationList, b: TopOperationList): number => a.p95 - b.p95,
|
2021-10-20 09:24:55 +05:30
|
|
|
render: (value: number): string => (value / 1000000).toFixed(2),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'P99 (in ms)',
|
|
|
|
|
dataIndex: 'p99',
|
|
|
|
|
key: 'p99',
|
2023-02-02 16:53:15 +05:30
|
|
|
width: 50,
|
2023-04-27 17:17:15 +05:30
|
|
|
sorter: (a: TopOperationList, b: TopOperationList): number => a.p99 - b.p99,
|
2021-10-20 09:24:55 +05:30
|
|
|
render: (value: number): string => (value / 1000000).toFixed(2),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Number of Calls',
|
|
|
|
|
dataIndex: 'numCalls',
|
|
|
|
|
key: 'numCalls',
|
2023-02-02 16:53:15 +05:30
|
|
|
width: 50,
|
2023-04-27 17:17:15 +05:30
|
|
|
sorter: (a: TopOperationList, b: TopOperationList): number =>
|
2021-10-20 09:24:55 +05:30
|
|
|
a.numCalls - b.numCalls,
|
|
|
|
|
},
|
2023-04-27 17:17:15 +05:30
|
|
|
{
|
|
|
|
|
title: 'Error Rate',
|
|
|
|
|
dataIndex: 'errorCount',
|
|
|
|
|
key: 'errorCount',
|
|
|
|
|
width: 50,
|
2023-06-12 18:19:07 +05:30
|
|
|
sorter: (first: TopOperationList, second: TopOperationList): number =>
|
|
|
|
|
getErrorRate(first) - getErrorRate(second),
|
|
|
|
|
render: (_, record: TopOperationList): string =>
|
|
|
|
|
`${getErrorRate(record).toFixed(2)} %`,
|
2023-04-27 17:17:15 +05:30
|
|
|
},
|
2021-10-20 09:24:55 +05:30
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return (
|
2023-02-03 18:06:26 +05:30
|
|
|
<ResizeTable
|
|
|
|
|
columns={columns}
|
|
|
|
|
showHeader
|
|
|
|
|
title={(): string => 'Key Operations'}
|
|
|
|
|
tableLayout="fixed"
|
|
|
|
|
dataSource={data}
|
|
|
|
|
rowKey="name"
|
|
|
|
|
/>
|
2021-10-20 09:24:55 +05:30
|
|
|
);
|
2022-03-22 12:10:31 +05:30
|
|
|
}
|
2021-10-20 09:24:55 +05:30
|
|
|
|
2023-04-27 17:17:15 +05:30
|
|
|
export interface TopOperationList {
|
2022-03-24 12:06:57 +05:30
|
|
|
p50: number;
|
|
|
|
|
p95: number;
|
|
|
|
|
p99: number;
|
|
|
|
|
numCalls: number;
|
|
|
|
|
name: string;
|
2023-04-27 17:17:15 +05:30
|
|
|
errorCount: number;
|
2022-03-24 12:06:57 +05:30
|
|
|
}
|
|
|
|
|
|
2022-08-04 11:57:05 +05:30
|
|
|
interface TopOperationsTableProps {
|
2023-04-27 17:17:15 +05:30
|
|
|
data: TopOperationList[];
|
2021-10-20 09:24:55 +05:30
|
|
|
}
|
|
|
|
|
|
2022-08-04 11:57:05 +05:30
|
|
|
export default TopOperationsTable;
|