Skip to content

Commit

Permalink
[APM] Remove duplicated logic in getIsUsingTransactionEvents (elastic…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar authored Feb 22, 2022
1 parent be4caac commit 67a38e6
Showing 1 changed file with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import { getSearchAggregatedTransactions } from '.';
import { SearchAggregatedTransactionSetting } from '../../../../common/aggregated_transactions';
import { Setup } from '../setup_request';
import { kqlQuery, rangeQuery } from '../../../../../observability/server';
import { ProcessorEvent } from '../../../../common/processor_event';
import { APMEventClient } from '../create_es_client/create_apm_event_client';
import { SearchAggregatedTransactionSetting } from '../../../../common/aggregated_transactions';

export async function getIsUsingTransactionEvents({
setup: { config, apmEventClient },
Expand All @@ -23,20 +23,6 @@ export async function getIsUsingTransactionEvents({
start?: number;
end?: number;
}): Promise<boolean> {
const searchAggregatedTransactions = config.searchAggregatedTransactions;

if (
searchAggregatedTransactions === SearchAggregatedTransactionSetting.never
) {
return false;
}
if (
!kuery &&
searchAggregatedTransactions === SearchAggregatedTransactionSetting.always
) {
return false;
}

const searchesAggregatedTransactions = await getSearchAggregatedTransactions({
config,
start,
Expand All @@ -45,7 +31,11 @@ export async function getIsUsingTransactionEvents({
kuery,
});

if (!searchesAggregatedTransactions) {
if (
!searchesAggregatedTransactions &&
config.searchAggregatedTransactions !==
SearchAggregatedTransactionSetting.never
) {
// if no aggregrated transactions, check if any transactions at all
return await getHasTransactions({
start,
Expand Down

0 comments on commit 67a38e6

Please sign in to comment.