From 9ed6ad0b267783cdd4354754a1ce68dd5f3e2995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Thu, 29 Nov 2018 23:13:48 +0100 Subject: [PATCH] =?UTF-8?q?Renamed=20=E2=80=9CdurationSum=E2=80=9D=20to=20?= =?UTF-8?q?=E2=80=9Csum=E2=80=9D=20and=20went=20back=20to=20single,=20muta?= =?UTF-8?q?ble=20impact?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/fetcher.test.ts.snap | 12 ++--- .../__snapshots__/transform.test.ts.snap | 23 ---------- .../server/lib/transaction_groups/fetcher.ts | 20 ++------ .../transactionGroupsResponse.ts | 46 +++++++++---------- .../lib/transaction_groups/transform.test.ts | 9 ++-- .../lib/transaction_groups/transform.ts | 9 ++-- 6 files changed, 42 insertions(+), 77 deletions(-) diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/fetcher.test.ts.snap b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/fetcher.test.ts.snap index 42240a161b46a..3701094ba818b 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/fetcher.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/fetcher.test.ts.snap @@ -14,11 +14,6 @@ Array [ "field": "transaction.duration.us", }, }, - "durationSum": Object { - "sum": Object { - "field": "transaction.duration.us", - }, - }, "p95": Object { "percentiles": Object { "field": "transaction.duration.us", @@ -42,11 +37,16 @@ Array [ ], }, }, + "sum": Object { + "sum": Object { + "field": "transaction.duration.us", + }, + }, }, "terms": Object { "field": "transaction.name.keyword", "order": Object { - "durationSum": "desc", + "sum": "desc", }, "size": 100, }, diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/transform.test.ts.snap b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/transform.test.ts.snap index ea5aa8b0aa6ec..2d8b16e95f769 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/transform.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/transform.test.ts.snap @@ -3,7 +3,6 @@ exports[`transactionGroupsTransformer should match snapshot 1`] = ` Array [ Object { - "absoluteImpact": 46073935, "averageResponseTime": 255966.30555555556, "impact": 4.3693406535517445, "name": "POST /api/orders", @@ -129,7 +128,6 @@ baz", "transactionsPerMinute": 5684.210526315789, }, Object { - "absoluteImpact": 1052209442, "averageResponseTime": 48021.972616494, "impact": 100, "name": "GET /api", @@ -256,7 +254,6 @@ baz", "transactionsPerMinute": 691926.3157894736, }, Object { - "absoluteImpact": 108011563, "averageResponseTime": 33265.03326147213, "impact": 10.256357027376065, "name": "GET /api/orders", @@ -378,7 +375,6 @@ baz", "transactionsPerMinute": 102536.84210526315, }, Object { - "absoluteImpact": 23030509, "averageResponseTime": 32900.72714285714, "impact": 2.1791207411745854, "name": "GET /log-message", @@ -500,7 +496,6 @@ baz", "transactionsPerMinute": 22105.263157894737, }, Object { - "absoluteImpact": 151019688, "averageResponseTime": 32554.36257814184, "impact": 14.344171563678346, "name": "GET /api/stats", @@ -628,7 +623,6 @@ baz", "transactionsPerMinute": 146494.73684210525, }, Object { - "absoluteImpact": 23837374, "averageResponseTime": 32387.73641304348, "impact": 2.2558112380477584, "name": "GET /log-error", @@ -750,7 +744,6 @@ baz", "transactionsPerMinute": 23242.105263157893, }, Object { - "absoluteImpact": 108250312, "averageResponseTime": 32159.926322043968, "impact": 10.27904952170656, "name": "GET /api/customers", @@ -878,7 +871,6 @@ baz", "transactionsPerMinute": 106294.73684210525, }, Object { - "absoluteImpact": 101647397, "averageResponseTime": 27516.89144558744, "impact": 9.651458992731666, "name": "GET /api/products/top", @@ -1007,7 +999,6 @@ baz", "transactionsPerMinute": 116652.63157894736, }, Object { - "absoluteImpact": 3135762, "averageResponseTime": 21331.714285714286, "impact": 0.28817487960409877, "name": "POST /api", @@ -1131,7 +1122,6 @@ baz", "transactionsPerMinute": 4642.105263157894, }, Object { - "absoluteImpact": 36131970, "averageResponseTime": 17189.329210275926, "impact": 3.424381787142002, "name": "GET /api/products/:id/customers", @@ -1259,7 +1249,6 @@ baz", "transactionsPerMinute": 66378.94736842105, }, Object { - "absoluteImpact": 18494584, "averageResponseTime": 12763.68806073154, "impact": 1.7479924334286208, "name": "GET /api/types/:id", @@ -1381,7 +1370,6 @@ baz", "transactionsPerMinute": 45757.8947368421, }, Object { - "absoluteImpact": 46648776, "averageResponseTime": 12683.190864600327, "impact": 4.4239778504968, "name": "GET /api/products", @@ -1503,7 +1491,6 @@ baz", "transactionsPerMinute": 116147.36842105263, }, Object { - "absoluteImpact": 27018619, "averageResponseTime": 11257.757916666667, "impact": 2.558180605569336, "name": "GET /api/types", @@ -1625,7 +1612,6 @@ baz", "transactionsPerMinute": 75789.47368421052, }, Object { - "absoluteImpact": 13579338, "averageResponseTime": 10584.05144193297, "impact": 1.280810614916383, "name": "GET /api/orders/:id", @@ -1745,7 +1731,6 @@ baz", "transactionsPerMinute": 40515.789473684206, }, Object { - "absoluteImpact": 19398174, "averageResponseTime": 10548.218597063622, "impact": 1.8338763992340905, "name": "GET /api/products/:id", @@ -1867,7 +1852,6 @@ baz", "transactionsPerMinute": 58073.68421052631, }, Object { - "absoluteImpact": 18749614, "averageResponseTime": 9868.217894736843, "impact": 1.7722323960215767, "name": "GET /api/customers/:id", @@ -1995,7 +1979,6 @@ baz", "transactionsPerMinute": 59999.99999999999, }, Object { - "absoluteImpact": 103858, "averageResponseTime": 5192.9, "impact": 0, "name": "POST unknown route", @@ -2127,7 +2110,6 @@ baz", "transactionsPerMinute": 631.578947368421, }, Object { - "absoluteImpact": 1680454, "averageResponseTime": 4694.005586592179, "impact": 0.1498515000753004, "name": "GET /is-it-coffee-time", @@ -2250,7 +2232,6 @@ baz", "transactionsPerMinute": 11305.263157894737, }, Object { - "absoluteImpact": 1528763, "averageResponseTime": 4549.889880952381, "impact": 0.13543365054509587, "name": "GET /throw-error", @@ -2373,7 +2354,6 @@ baz", "transactionsPerMinute": 10610.526315789473, }, Object { - "absoluteImpact": 24934595, "averageResponseTime": 3504.5108924806746, "impact": 2.3600993453143766, "name": "GET *", @@ -2501,7 +2481,6 @@ baz", "transactionsPerMinute": 224684.21052631576, }, Object { - "absoluteImpact": 998256, "averageResponseTime": 2742.4615384615386, "impact": 0.08501028923348058, "name": "OPTIONS unknown route", @@ -2625,7 +2604,6 @@ baz", "transactionsPerMinute": 11494.736842105262, }, Object { - "absoluteImpact": 166023502, "averageResponseTime": 2651.8784461553205, "impact": 15.770246496477105, "name": "GET static file", @@ -2734,7 +2712,6 @@ baz", "transactionsPerMinute": 1977031.5789473683, }, Object { - "absoluteImpact": 10653452, "averageResponseTime": 1422.926672899693, "impact": 1.0027124806135428, "name": "GET unknown route", diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts index 8c976477de8c0..ad0aa00d35bc9 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts @@ -16,17 +16,9 @@ import { Setup } from '../helpers/setup_request'; interface Bucket { key: string; doc_count: number; - avg: { - value: number; - }; - p95: { - values: { - '95.0': number; - }; - }; - durationSum: { - value: number; - }; + avg: { value: number }; + p95: { values: { '95.0': number } }; + sum: { value: number }; sample: { hits: { total: number; @@ -60,7 +52,7 @@ export function transactionGroupsFetcher( transactions: { terms: { field: `${TRANSACTION_NAME}.keyword`, - order: { durationSum: 'desc' }, + order: { sum: 'desc' }, size: 100 }, aggs: { @@ -77,9 +69,7 @@ export function transactionGroupsFetcher( p95: { percentiles: { field: TRANSACTION_DURATION, percents: [95] } }, - durationSum: { - sum: { field: 'transaction.duration.us' } - } + sum: { sum: { field: TRANSACTION_DURATION } } } } } diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/mock-responses/transactionGroupsResponse.ts b/x-pack/plugins/apm/server/lib/transaction_groups/mock-responses/transactionGroupsResponse.ts index 5a90a9f9e61a6..2632cc6e94b93 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/mock-responses/transactionGroupsResponse.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/mock-responses/transactionGroupsResponse.ts @@ -21,7 +21,7 @@ export const transactionGroupsResponse = ({ doc_count: 180, avg: { value: 255966.30555555556 }, p95: { values: { '95.0': 320238.5 } }, - durationSum: { value: 46073935 }, + sum: { value: 46073935 }, sample: { hits: { total: 180, @@ -141,7 +141,7 @@ export const transactionGroupsResponse = ({ doc_count: 21911, avg: { value: 48021.972616494 }, p95: { values: { '95.0': 67138.18364917398 } }, - durationSum: { value: 1052209442 }, + sum: { value: 1052209442 }, sample: { hits: { total: 21911, @@ -261,7 +261,7 @@ export const transactionGroupsResponse = ({ doc_count: 3247, avg: { value: 33265.03326147213 }, p95: { values: { '95.0': 58827.489999999976 } }, - durationSum: { value: 108011563 }, + sum: { value: 108011563 }, sample: { hits: { total: 3247, @@ -377,7 +377,7 @@ export const transactionGroupsResponse = ({ doc_count: 700, avg: { value: 32900.72714285714 }, p95: { values: { '95.0': 40444 } }, - durationSum: { value: 23030509 }, + sum: { value: 23030509 }, sample: { hits: { total: 700, @@ -493,7 +493,7 @@ export const transactionGroupsResponse = ({ doc_count: 4639, avg: { value: 32554.36257814184 }, p95: { values: { '95.0': 59356.73611111111 } }, - durationSum: { value: 151019688 }, + sum: { value: 151019688 }, sample: { hits: { total: 4639, @@ -614,7 +614,7 @@ export const transactionGroupsResponse = ({ doc_count: 736, avg: { value: 32387.73641304348 }, p95: { values: { '95.0': 40061.1 } }, - durationSum: { value: 23837374 }, + sum: { value: 23837374 }, sample: { hits: { total: 736, @@ -730,7 +730,7 @@ export const transactionGroupsResponse = ({ doc_count: 3366, avg: { value: 32159.926322043968 }, p95: { values: { '95.0': 59845.85714285714 } }, - durationSum: { value: 108250312 }, + sum: { value: 108250312 }, sample: { hits: { total: 3366, @@ -851,7 +851,7 @@ export const transactionGroupsResponse = ({ doc_count: 3694, avg: { value: 27516.89144558744 }, p95: { values: { '95.0': 56064.679999999986 } }, - durationSum: { value: 101647397 }, + sum: { value: 101647397 }, sample: { hits: { total: 3694, @@ -973,7 +973,7 @@ export const transactionGroupsResponse = ({ doc_count: 147, avg: { value: 21331.714285714286 }, p95: { values: { '95.0': 30938 } }, - durationSum: { value: 3135762 }, + sum: { value: 3135762 }, sample: { hits: { total: 147, @@ -1091,7 +1091,7 @@ export const transactionGroupsResponse = ({ doc_count: 2102, avg: { value: 17189.329210275926 }, p95: { values: { '95.0': 39284.79999999999 } }, - durationSum: { value: 36131970 }, + sum: { value: 36131970 }, sample: { hits: { total: 2102, @@ -1213,7 +1213,7 @@ export const transactionGroupsResponse = ({ doc_count: 1449, avg: { value: 12763.68806073154 }, p95: { values: { '95.0': 30576.749999999996 } }, - durationSum: { value: 18494584 }, + sum: { value: 18494584 }, sample: { hits: { total: 1449, @@ -1329,7 +1329,7 @@ export const transactionGroupsResponse = ({ doc_count: 3678, avg: { value: 12683.190864600327 }, p95: { values: { '95.0': 35009.67999999999 } }, - durationSum: { value: 46648776 }, + sum: { value: 46648776 }, sample: { hits: { total: 3678, @@ -1445,7 +1445,7 @@ export const transactionGroupsResponse = ({ doc_count: 2400, avg: { value: 11257.757916666667 }, p95: { values: { '95.0': 35222.944444444445 } }, - durationSum: { value: 27018619 }, + sum: { value: 27018619 }, sample: { hits: { total: 2400, @@ -1561,7 +1561,7 @@ export const transactionGroupsResponse = ({ doc_count: 1283, avg: { value: 10584.05144193297 }, p95: { values: { '95.0': 26555.399999999998 } }, - durationSum: { value: 13579338 }, + sum: { value: 13579338 }, sample: { hits: { total: 1283, @@ -1675,7 +1675,7 @@ export const transactionGroupsResponse = ({ doc_count: 1839, avg: { value: 10548.218597063622 }, p95: { values: { '95.0': 28413.383333333328 } }, - durationSum: { value: 19398174 }, + sum: { value: 19398174 }, sample: { hits: { total: 1839, @@ -1791,7 +1791,7 @@ export const transactionGroupsResponse = ({ doc_count: 1900, avg: { value: 9868.217894736843 }, p95: { values: { '95.0': 27486.5 } }, - durationSum: { value: 18749614 }, + sum: { value: 18749614 }, sample: { hits: { total: 1900, @@ -1912,7 +1912,7 @@ export const transactionGroupsResponse = ({ doc_count: 20, avg: { value: 5192.9 }, p95: { values: { '95.0': 13230.5 } }, - durationSum: { value: 103858 }, + sum: { value: 103858 }, sample: { hits: { total: 20, @@ -2038,7 +2038,7 @@ export const transactionGroupsResponse = ({ doc_count: 358, avg: { value: 4694.005586592179 }, p95: { values: { '95.0': 11022.99999999992 } }, - durationSum: { value: 1680454 }, + sum: { value: 1680454 }, sample: { hits: { total: 358, @@ -2155,7 +2155,7 @@ export const transactionGroupsResponse = ({ doc_count: 336, avg: { value: 4549.889880952381 }, p95: { values: { '95.0': 7719.700000000001 } }, - durationSum: { value: 1528763 }, + sum: { value: 1528763 }, sample: { hits: { total: 336, @@ -2272,7 +2272,7 @@ export const transactionGroupsResponse = ({ doc_count: 7115, avg: { value: 3504.5108924806746 }, p95: { values: { '95.0': 11431.738095238095 } }, - durationSum: { value: 24934595 }, + sum: { value: 24934595 }, sample: { hits: { total: 7115, @@ -2395,7 +2395,7 @@ export const transactionGroupsResponse = ({ doc_count: 364, avg: { value: 2742.4615384615386 }, p95: { values: { '95.0': 4370.000000000002 } }, - durationSum: { value: 998256 }, + sum: { value: 998256 }, sample: { hits: { total: 364, @@ -2513,7 +2513,7 @@ export const transactionGroupsResponse = ({ doc_count: 62606, avg: { value: 2651.8784461553205 }, p95: { values: { '95.0': 6140.579335038363 } }, - durationSum: { value: 166023502 }, + sum: { value: 166023502 }, sample: { hits: { total: 62606, @@ -2618,7 +2618,7 @@ export const transactionGroupsResponse = ({ doc_count: 7487, avg: { value: 1422.926672899693 }, p95: { values: { '95.0': 2311.885238095238 } }, - durationSum: { value: 10653452 }, + sum: { value: 10653452 }, sample: { hits: { total: 7487, diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/transform.test.ts b/x-pack/plugins/apm/server/lib/transaction_groups/transform.test.ts index bd23fc3c60d7a..6acd34af24353 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/transform.test.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/transform.test.ts @@ -25,7 +25,7 @@ describe('transactionGroupsTransformer', () => { doc_count: 180, avg: { value: 255966.30555555556 }, p95: { values: { '95.0': 320238.5 } }, - durationSum: { value: 3000000000 }, + sum: { value: 3000000000 }, sample: { hits: { total: 180, @@ -48,7 +48,6 @@ describe('transactionGroupsTransformer', () => { { averageResponseTime: 255966.30555555556, impact: 0, - absoluteImpact: 3000000000, name: 'POST /api/orders', p95: 320238.5, sample: 'sample source', @@ -57,13 +56,13 @@ describe('transactionGroupsTransformer', () => { ]); }); - it('should calculate relative impact from durationSum', () => { - const getBucket = (durationSum: number) => ({ + it('should calculate impact from sum', () => { + const getBucket = (sum: number) => ({ key: 'POST /api/orders', doc_count: 180, avg: { value: 300000 }, p95: { values: { '95.0': 320000 } }, - durationSum: { value: durationSum }, + sum: { value: sum }, sample: { hits: { total: 180, hits: [{ _source: 'sample source' }] } } }); diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts b/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts index cde3db16c5b5e..53f8ca04d4ee6 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts @@ -16,17 +16,16 @@ export interface ITransactionGroup { averageResponseTime: number; transactionsPerMinute: number; impact: number; - absoluteImpact: number; } function calculateRelativeImpacts(results: ITransactionGroup[]) { - const values = results.map(({ absoluteImpact }) => absoluteImpact); + const values = results.map(({ impact }) => impact); const max = Math.max(...values); const min = Math.min(...values); return results.map(bucket => ({ ...bucket, - impact: ((bucket.absoluteImpact - min) / (max - min)) * 100 || 0 + impact: ((bucket.impact - min) / (max - min)) * 100 || 0 })); } @@ -45,6 +44,7 @@ export function transactionGroupsTransformer({ const results = buckets.map(bucket => { const averageResponseTime = bucket.avg.value; const transactionsPerMinute = bucket.doc_count / minutes; + const impact = bucket.sum.value; const sample = bucket.sample.hits.hits[0]._source; return { @@ -53,8 +53,7 @@ export function transactionGroupsTransformer({ p95: bucket.p95.values['95.0'], averageResponseTime, transactionsPerMinute, - impact: 0, - absoluteImpact: bucket.durationSum.value + impact }; });