Skip to content

Commit

Permalink
Conditionally add should params in transaction distribution ES query
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Jul 31, 2019
1 parent 2e25b6a commit 7f7cfbc
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ export function bucketFetcher({
const { start, end, uiFiltersES, client, config } = setup;
const bucketTargetCount = config.get<number>('xpack.apm.bucketTargetCount');

const should: Array<Record<string, any>> = [
{ term: { [TRANSACTION_SAMPLED]: true } }
];

if (traceId) {
should.push({ term: { [TRACE_ID]: traceId } });
}

if (transactionId) {
should.push({ term: { [TRANSACTION_ID]: transactionId } });
}

const params = {
index: config.get<string>('apm_oss.transactionIndices'),
body: {
Expand All @@ -51,11 +63,7 @@ export function bucketFetcher({
{ range: rangeFilter(start, end) },
...uiFiltersES
],
should: [
{ term: { [TRACE_ID]: traceId } }, // TODO: might fail when undefined
{ term: { [TRANSACTION_ID]: transactionId } }, // TODO: might fail when undefined
{ term: { [TRANSACTION_SAMPLED]: true } }
]
should
}
},
aggs: {
Expand Down

0 comments on commit 7f7cfbc

Please sign in to comment.