[APM] Immediately return terms for unbound queries (#74543)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
25c176255a
commit
3e077973e8
|
@ -37,6 +37,9 @@ export async function getAllEnvironments({
|
|||
],
|
||||
},
|
||||
body: {
|
||||
// use timeout + min_doc_count to return as early as possible
|
||||
// if filter is not defined to prevent timeouts
|
||||
...(!serviceName ? { timeout: '1ms' } : {}),
|
||||
size: 0,
|
||||
query: {
|
||||
bool: {
|
||||
|
@ -48,6 +51,7 @@ export async function getAllEnvironments({
|
|||
terms: {
|
||||
field: SERVICE_ENVIRONMENT,
|
||||
size: 100,
|
||||
...(!serviceName ? { min_doc_count: 0 } : {}),
|
||||
missing: includeMissing ? ENVIRONMENT_NOT_DEFINED.value : undefined,
|
||||
},
|
||||
},
|
||||
|
@ -56,6 +60,7 @@ export async function getAllEnvironments({
|
|||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
|
||||
const environments =
|
||||
resp.aggregations?.environments.buckets.map(
|
||||
(bucket) => bucket.key as string
|
||||
|
|
|
@ -34,7 +34,7 @@ export async function callClientWithDebug({
|
|||
let res: any;
|
||||
let esError = null;
|
||||
try {
|
||||
res = apiCaller(operationName, params);
|
||||
res = await apiCaller(operationName, params);
|
||||
} catch (e) {
|
||||
// catch error and throw after outputting debug info
|
||||
esError = e;
|
||||
|
|
|
@ -127,11 +127,13 @@ Object {
|
|||
"services": Object {
|
||||
"terms": Object {
|
||||
"field": "service.name",
|
||||
"min_doc_count": 0,
|
||||
"size": 50,
|
||||
},
|
||||
},
|
||||
},
|
||||
"size": 0,
|
||||
"timeout": "1ms",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -25,12 +25,14 @@ export async function getServiceNames({ setup }: { setup: Setup }) {
|
|||
],
|
||||
},
|
||||
body: {
|
||||
timeout: '1ms',
|
||||
size: 0,
|
||||
aggs: {
|
||||
services: {
|
||||
terms: {
|
||||
field: SERVICE_NAME,
|
||||
size: 50,
|
||||
min_doc_count: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue