diff --git a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts index 478f3218ef38c..d5e254f7e9656 100644 --- a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts @@ -66,16 +66,21 @@ export async function getSearchAggregatedTransactions({ const searchAggregatedTransactions = config['xpack.apm.searchAggregatedTransactions']; - if ( - kuery || - searchAggregatedTransactions === SearchAggregatedTransactionSetting.auto - ) { - return getHasAggregatedTransactions({ start, end, apmEventClient, kuery }); + switch (searchAggregatedTransactions) { + case SearchAggregatedTransactionSetting.always: + return kuery + ? getHasAggregatedTransactions({ start, end, apmEventClient, kuery }) + : true; + case SearchAggregatedTransactionSetting.auto: + return getHasAggregatedTransactions({ + start, + end, + apmEventClient, + kuery, + }); + case SearchAggregatedTransactionSetting.never: + return false; } - - return ( - searchAggregatedTransactions === SearchAggregatedTransactionSetting.always - ); } export function getTransactionDurationFieldForAggregatedTransactions(