diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/do_work.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/do_work.ts deleted file mode 100644 index 3c656d3efb9f17..00000000000000 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/do_work.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export const doWork = async (fn: () => T): Promise => { - return new Promise((resolve) => { - setTimeout(() => { - resolve(fn()); - }); - }); -}; diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_rule.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_rule.ts index 970c684b98d37c..e1f4f974cf127f 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_rule.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_rule.ts @@ -22,7 +22,6 @@ import { UNGROUPED_FACTORY_KEY } from '../../common/utils'; import { MetricExpressionParams, Comparator, Aggregators } from '../types'; import { getElasticsearchMetricQuery } from './metric_query'; import { createTimerange } from './create_timerange'; -import { doWork } from './do_work'; interface AggregationWithoutIntervals { aggregatedValue: { value: number; values?: Array<{ key: number; value: number }> }; @@ -204,23 +203,17 @@ const getMetric: ( afterKeyHandler )) as Array; doc_count: number }>; const groupedResults: Record = {}; - await Promise.all( - compositeBuckets.map((bucket) => { - return doWork(() => { - const key = Object.values(bucket.key) - .map((value) => value) - .join(', '); - const value = getValuesFromAggregations( - bucket, - aggType, - dropPartialBucketsOptions, - calculatedTimerange, - bucket.doc_count - ); - groupedResults[key] = value; - }); - }) - ); + for (const bucket of compositeBuckets) { + const key = Object.values(bucket.key).join(', '); + const value = getValuesFromAggregations( + bucket, + aggType, + dropPartialBucketsOptions, + calculatedTimerange, + bucket.doc_count + ); + groupedResults[key] = value; + } return groupedResults; } const { body: result } = await esClient.search({