Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Break down transaction table api removing the sparklines #88946

Merged
merged 45 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f2a32af
removing pagination from server
cauemarcondes Jan 21, 2021
22b3729
new metrics api
cauemarcondes Jan 21, 2021
654928d
adding api tests
cauemarcondes Jan 25, 2021
284b39d
fixing TS
cauemarcondes Jan 25, 2021
d5b871d
new metrics api
cauemarcondes Jan 25, 2021
89b845c
fixing TS
cauemarcondes Jan 25, 2021
0a3b800
addressing PR comments
cauemarcondes Jan 26, 2021
8a10a56
addressing PR comments
cauemarcondes Jan 26, 2021
3eaf6b7
addressing PR comments
cauemarcondes Jan 26, 2021
a57e3ff
Merge branch 'master' of github.com:elastic/kibana into apm-transacti…
cauemarcondes Feb 1, 2021
aab9c33
addressing PR comments
cauemarcondes Feb 1, 2021
ad4f99d
adding API test
cauemarcondes Feb 1, 2021
bf9647f
changing how to calculate impact
cauemarcondes Feb 1, 2021
71ca8cd
Merge branch 'master' of github.com:elastic/kibana into apm-transacti…
cauemarcondes Feb 1, 2021
ca17de7
fixing conflicts
cauemarcondes Feb 1, 2021
502f709
caching result
cauemarcondes Feb 1, 2021
2967f65
Merge branch 'master' of github.com:elastic/kibana into apm-transacti…
cauemarcondes Feb 2, 2021
fa2ad69
addressing PR comments
cauemarcondes Feb 3, 2021
2b5f7d0
Merge branch 'master' of github.com:elastic/kibana into apm-transacti…
cauemarcondes Feb 3, 2021
dd58608
Merge branch 'master' of github.com:elastic/kibana into apm-transacti…
cauemarcondes Feb 4, 2021
9b4e84c
fixing license
cauemarcondes Feb 4, 2021
c725a6e
renaming
cauemarcondes Feb 4, 2021
51c66d9
using rate agg to calculate throughput
cauemarcondes Feb 4, 2021
a37637d
Removing unused variable
cauemarcondes Feb 5, 2021
80f12b8
addressing PR comments
cauemarcondes Feb 5, 2021
7ed0238
Merge branch 'apm-transaction-table-api' of github.com:cauemarcondes/…
cauemarcondes Feb 5, 2021
19b395f
addressing PR comments
cauemarcondes Feb 6, 2021
b38f92a
Merge branch 'master' of github.com:elastic/kibana into apm-transacti…
cauemarcondes Feb 6, 2021
2e7c224
fixing error rate
cauemarcondes Feb 6, 2021
8d33fb3
fixing eslint
cauemarcondes Feb 7, 2021
85e4b94
addressing PR comments
cauemarcondes Feb 8, 2021
a67632f
fixig TS issue
cauemarcondes Feb 8, 2021
b15cb64
Merge branch 'master' into apm-transaction-table-api
kibanamachine Feb 8, 2021
daf88fe
removing requestId
cauemarcondes Feb 9, 2021
6d10b2f
addressing PR comments
cauemarcondes Feb 9, 2021
90ccb07
Merge branch 'apm-transaction-table-api' of github.com:cauemarcondes/…
cauemarcondes Feb 9, 2021
21701f1
Merge branch 'master' of github.com:elastic/kibana into apm-transacti…
dgieselaar Feb 9, 2021
e1e2fb8
Merge branch 'master' of github.com:elastic/kibana into apm-transacti…
dgieselaar Feb 9, 2021
d0348c7
Merge branch 'apm-transaction-table-api' of github.com:cauemarcondes/…
dgieselaar Feb 9, 2021
e90fa6c
adding requestId
cauemarcondes Feb 10, 2021
ae5760e
Merge branch 'master' into apm-transaction-table-api
kibanamachine Feb 12, 2021
2c0305d
Merge branch 'apm-transaction-table-api' of github.com:cauemarcondes/…
dgieselaar Feb 12, 2021
4370be1
Revert "adding requestId"
dgieselaar Feb 12, 2021
c490067
Revert "removing requestId"
dgieselaar Feb 12, 2021
f7d2157
Support for transaction duration metrics
dgieselaar Feb 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useState } from 'react';
import React, { useMemo, useState } from 'react';
import { ValuesType } from 'utility-types';
import { LatencyAggregationType } from '../../../../../common/latency_aggregation_types';
import {
Expand Down Expand Up @@ -40,6 +40,8 @@ type ServiceTransactionGroupItem = ValuesType<
APIReturnType<'GET /api/apm/services/{serviceName}/transactions/groups/overview'>['transactionGroups']
>;

type TransactionGroupMetrics = APIReturnType<'GET /api/apm/services/{serviceName}/transactions/groups/metrics'>;

interface Props {
serviceName: string;
}
Expand Down Expand Up @@ -81,90 +83,16 @@ function getLatencyAggregationTypeLabel(latencyAggregationType?: string) {
}
}

export function ServiceOverviewTransactionsTable(props: Props) {
const { serviceName } = props;
const { transactionType } = useApmServiceContext();
const {
uiFilters,
urlParams: { start, end, latencyAggregationType },
} = useUrlParams();

const [tableOptions, setTableOptions] = useState<{
pageIndex: number;
sort: {
direction: SortDirection;
field: SortField;
};
}>({
pageIndex: 0,
sort: DEFAULT_SORT,
});

const {
data = {
totalItemCount: 0,
items: [],
tableOptions: {
pageIndex: 0,
sort: DEFAULT_SORT,
},
},
status,
} = useFetcher(() => {
if (!start || !end || !latencyAggregationType || !transactionType) {
return;
}

return callApmApi({
endpoint:
'GET /api/apm/services/{serviceName}/transactions/groups/overview',
params: {
path: { serviceName },
query: {
start,
end,
uiFilters: JSON.stringify(uiFilters),
size: PAGE_SIZE,
numBuckets: 20,
pageIndex: tableOptions.pageIndex,
sortField: tableOptions.sort.field,
sortDirection: tableOptions.sort.direction,
transactionType,
latencyAggregationType: latencyAggregationType as LatencyAggregationType,
},
},
}).then((response) => {
return {
items: response.transactionGroups,
totalItemCount: response.totalTransactionGroups,
tableOptions: {
pageIndex: tableOptions.pageIndex,
sort: {
field: tableOptions.sort.field,
direction: tableOptions.sort.direction,
},
},
};
});
}, [
serviceName,
start,
end,
uiFilters,
tableOptions.pageIndex,
tableOptions.sort.field,
tableOptions.sort.direction,
transactionType,
latencyAggregationType,
]);

const {
items,
totalItemCount,
tableOptions: { pageIndex, sort },
} = data;

const columns: Array<EuiBasicTableColumn<ServiceTransactionGroupItem>> = [
function getColumns({
serviceName,
latencyAggregationType,
transactionsMetricsData,
}: {
serviceName: string;
latencyAggregationType?: string;
transactionsMetricsData?: TransactionGroupMetrics;
}): Array<EuiBasicTableColumn<ServiceTransactionGroupItem>> {
return [
{
field: 'name',
name: i18n.translate(
Expand Down Expand Up @@ -195,12 +123,15 @@ export function ServiceOverviewTransactionsTable(props: Props) {
field: 'latency',
name: getLatencyAggregationTypeLabel(latencyAggregationType),
width: px(unit * 10),
render: (_, { latency }) => {
render: (_, { latency, name }) => {
const timeseries = transactionsMetricsData
? transactionsMetricsData[name]?.latency.timeseries
: undefined;
return (
<SparkPlot
color="euiColorVis1"
compact
series={latency.timeseries ?? undefined}
series={timeseries}
valueLabel={asMillisecondDuration(latency.value)}
/>
);
Expand All @@ -213,12 +144,15 @@ export function ServiceOverviewTransactionsTable(props: Props) {
{ defaultMessage: 'Throughput' }
),
width: px(unit * 10),
render: (_, { throughput }) => {
render: (_, { throughput, name }) => {
const timeseries = transactionsMetricsData
? transactionsMetricsData[name]?.throughput.timeseries
: undefined;
return (
<SparkPlot
color="euiColorVis0"
compact
series={throughput.timeseries ?? undefined}
series={timeseries}
valueLabel={asTransactionRate(throughput.value)}
/>
);
Expand All @@ -233,12 +167,15 @@ export function ServiceOverviewTransactionsTable(props: Props) {
}
),
width: px(unit * 8),
render: (_, { errorRate }) => {
render: (_, { errorRate, name }) => {
const timeseries = transactionsMetricsData
? transactionsMetricsData[name]?.errorRate.timeseries
: undefined;
return (
<SparkPlot
color="euiColorVis7"
compact
series={errorRate.timeseries ?? undefined}
series={timeseries}
valueLabel={asPercent(errorRate.value, 1)}
/>
);
Expand All @@ -258,6 +195,127 @@ export function ServiceOverviewTransactionsTable(props: Props) {
},
},
];
}

export function ServiceOverviewTransactionsTable(props: Props) {
const { serviceName } = props;
const { transactionType } = useApmServiceContext();
const {
uiFilters,
urlParams: { start, end, latencyAggregationType },
} = useUrlParams();

const [tableOptions, setTableOptions] = useState<{
pageIndex: number;
sort: {
direction: SortDirection;
field: SortField;
};
}>({
pageIndex: 0,
sort: DEFAULT_SORT,
});

const {
data = {
totalItemCount: 0,
items: [],
tableOptions: {
pageIndex: 0,
sort: DEFAULT_SORT,
},
},
status,
} = useFetcher(() => {
if (!start || !end || !latencyAggregationType || !transactionType) {
return;
}

return callApmApi({
endpoint:
'GET /api/apm/services/{serviceName}/transactions/groups/overview',
params: {
path: { serviceName },
query: {
start,
end,
uiFilters: JSON.stringify(uiFilters),
numBuckets: 20,
sortField: tableOptions.sort.field,
sortDirection: tableOptions.sort.direction,
transactionType,
latencyAggregationType: latencyAggregationType as LatencyAggregationType,
},
},
}).then((response) => {
return {
items: response.transactionGroups,
totalItemCount: response.totalTransactionGroups,
tableOptions: {
pageIndex: tableOptions.pageIndex,
sort: {
field: tableOptions.sort.field,
direction: tableOptions.sort.direction,
},
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
},
};
});
}, [
serviceName,
start,
end,
uiFilters,
tableOptions.pageIndex,
tableOptions.sort.field,
tableOptions.sort.direction,
transactionType,
latencyAggregationType,
]);

const {
items,
totalItemCount,
tableOptions: { pageIndex, sort },
} = data;

const transactionNames = useMemo(() => items.map(({ name }) => name), [
items,
]);

const {
data: transactionsMetricsData,
status: transactionsMetricsStatus,
} = useFetcher(
() => {
if (transactionNames.length && start && end && transactionType) {
return callApmApi({
endpoint:
'GET /api/apm/services/{serviceName}/transactions/groups/metrics',
params: {
path: { serviceName },
query: {
start,
end,
uiFilters: JSON.stringify(uiFilters),
numBuckets: 20,
transactionType,
latencyAggregationType: latencyAggregationType as LatencyAggregationType,
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
transactionNames: transactionNames.join(),
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
},
},
});
}
},
// only fetches metrics when transaction names change
// eslint-disable-next-line react-hooks/exhaustive-deps
[transactionNames]
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
);

const columns = getColumns({
serviceName,
latencyAggregationType,
transactionsMetricsData,
});

return (
<EuiFlexGroup direction="column" gutterSize="s">
Expand Down Expand Up @@ -300,15 +358,21 @@ export function ServiceOverviewTransactionsTable(props: Props) {
>
<EuiBasicTable
columns={columns}
items={items}
items={items.slice(
pageIndex * PAGE_SIZE,
(pageIndex + 1) * PAGE_SIZE
)}
pagination={{
pageIndex,
pageSize: PAGE_SIZE,
totalItemCount,
pageSizeOptions: [PAGE_SIZE],
hidePerPageOptions: true,
}}
loading={status === FETCH_STATUS.LOADING}
loading={
status === FETCH_STATUS.LOADING ||
transactionsMetricsStatus === FETCH_STATUS.LOADING
}
onChange={(newTableOptions: {
page?: {
index: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Settings,
} from '@elastic/charts';
import { merge } from 'lodash';
import { Coordinate } from '../../../../../typings/timeseries';
import { useChartTheme } from '../../../../../../observability/public';
import { px, unit } from '../../../../style/variables';
import { useTheme } from '../../../../hooks/use_theme';
Expand All @@ -38,7 +39,7 @@ export function SparkPlot({
compact,
}: {
color: Color;
series?: Array<{ x: number; y: number | null }> | null;
series?: Coordinate[] | null;
valueLabel: React.ReactNode;
compact?: boolean;
}) {
Expand All @@ -57,18 +58,18 @@ export function SparkPlot({

const colorValue = theme.eui[color];

const chartSize = {
height: px(24),
width: compact ? px(unit * 3) : px(unit * 4),
};

return (
<EuiFlexGroup gutterSize="m" responsive={false}>
<EuiFlexItem grow={false}>
{!series || series.every((point) => point.y === null) ? (
<EuiIcon type="visLine" color="subdued" />
<EuiIcon type="visLine" color="subdued" style={chartSize} />
) : (
<Chart
size={{
height: px(24),
width: compact ? px(unit * 3) : px(unit * 4),
}}
>
<Chart size={chartSize}>
<Settings
theme={sparkplotChartTheme}
showLegend={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export async function getTimeseriesDataForTransactionGroups({
transactionNames,
esFilter,
searchAggregatedTransactions,
size,
numBuckets,
transactionType,
latencyAggregationType,
Expand All @@ -48,7 +47,6 @@ export async function getTimeseriesDataForTransactionGroups({
transactionNames: string[];
esFilter: ESFilter[];
searchAggregatedTransactions: boolean;
size: number;
numBuckets: number;
transactionType: string;
latencyAggregationType: LatencyAggregationType;
Expand Down Expand Up @@ -84,7 +82,7 @@ export async function getTimeseriesDataForTransactionGroups({
transaction_groups: {
terms: {
field: TRANSACTION_NAME,
size,
size: 500,
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
},
aggs: {
timeseries: {
Expand Down
Loading