Skip to content

Commit 1faaca6

Browse files
authored
[6.5] [APM] Move impact calculation to Elasticsearch (#26443)
1 parent 1faf657 commit 1faaca6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

x-pack/plugins/apm/server/lib/helpers/transaction_group_query.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface ITransactionGroupBucket {
2323
'95.0': number;
2424
};
2525
};
26+
sum: { value: number };
2627
sample: {
2728
hits: {
2829
hits: Array<{
@@ -36,7 +37,7 @@ export const TRANSACTION_GROUP_AGGREGATES = {
3637
transactions: {
3738
terms: {
3839
field: `${TRANSACTION_NAME}.keyword`,
39-
order: { avg: 'desc' },
40+
order: { sum: 'desc' },
4041
size: 100
4142
},
4243
aggs: {
@@ -47,7 +48,8 @@ export const TRANSACTION_GROUP_AGGREGATES = {
4748
}
4849
},
4950
avg: { avg: { field: TRANSACTION_DURATION } },
50-
p95: { percentiles: { field: TRANSACTION_DURATION, percents: [95] } }
51+
p95: { percentiles: { field: TRANSACTION_DURATION, percents: [95] } },
52+
sum: { sum: { field: TRANSACTION_DURATION } }
5153
}
5254
}
5355
};
@@ -78,7 +80,7 @@ export function prepareTransactionGroups({
7880
const results = buckets.map((bucket: ITransactionGroupBucket) => {
7981
const averageResponseTime = bucket.avg.value;
8082
const transactionsPerMinute = bucket.doc_count / minutes;
81-
const impact = Math.round(averageResponseTime * transactionsPerMinute);
83+
const impact = bucket.sum.value;
8284
const sample = bucket.sample.hits.hits[0]._source;
8385

8486
return {

0 commit comments

Comments
 (0)