From 3a335528bf4b645e90b19c92490a81aeebbb8848 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 3 Nov 2021 17:26:55 -0400 Subject: [PATCH] [APM] Don't use transaction metrics if set to never (#117370) (#117414) Closes #117226. Co-authored-by: Dario Gieselaar --- .../server/lib/helpers/transactions/index.ts | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/apm/server/lib/helpers/transactions/index.ts b/x-pack/plugins/apm/server/lib/helpers/transactions/index.ts index 473d34cd5b6fc..edaae8cadc1d5 100644 --- a/x-pack/plugins/apm/server/lib/helpers/transactions/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/transactions/index.ts @@ -63,18 +63,23 @@ export async function getSearchAggregatedTransactions({ apmEventClient: APMEventClient; kuery: string; }): Promise { - const searchAggregatedTransactions = config.searchAggregatedTransactions; + switch (config.searchAggregatedTransactions) { + case SearchAggregatedTransactionSetting.always: + return kuery + ? getHasAggregatedTransactions({ start, end, apmEventClient, kuery }) + : true; - if ( - kuery || - searchAggregatedTransactions === SearchAggregatedTransactionSetting.auto - ) { - return getHasAggregatedTransactions({ start, end, apmEventClient, kuery }); - } + case SearchAggregatedTransactionSetting.auto: + return getHasAggregatedTransactions({ + start, + end, + apmEventClient, + kuery, + }); - return ( - searchAggregatedTransactions === SearchAggregatedTransactionSetting.always - ); + case SearchAggregatedTransactionSetting.never: + return false; + } } export function getTransactionDurationFieldForTransactions(