Skip to content

Commit d874d57

Browse files
Colton Myersdgieselaar
andcommitted
[APM] Performance fix for 'cardinality' telemetry task (#144061)
* Performance fix for 'cardinality' telemetry task * Make timeout/index required for telemetry searches * Fix tests Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co> (cherry picked from commit a5c8ebe)
1 parent c5269b5 commit d874d57

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ type ISavedObjectsClient = Pick<SavedObjectsClient, 'find'>;
1717

1818
type TelemetryTaskExecutor = (params: {
1919
indices: ApmIndicesConfig;
20-
search<TSearchRequest extends ESSearchRequest>(
20+
search<
21+
TSearchRequest extends ESSearchRequest & { index: string | string[] } & {
22+
body: { timeout: string };
23+
}
24+
>(
2125
params: TSearchRequest
2226
): Promise<ESSearchResponse<unknown, TSearchRequest>>;
2327
indicesStats(

x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ describe('data telemetry collection tasks', () => {
433433
}
434434
});
435435

436-
expect(await task?.executor({ search } as any)).toEqual({
436+
expect(await task?.executor({ search, indices } as any)).toEqual({
437437
cardinality: {
438438
client: { geo: { country_iso_code: { rum: { '1d': 5 } } } },
439439
transaction: { name: { all_agents: { '1d': 3 }, rum: { '1d': 1 } } },

x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export const tasks: TelemetryTask[] = [
147147
await search({
148148
index: indices.transaction,
149149
body: {
150+
timeout,
150151
query: {
151152
bool: {
152153
filter: [
@@ -354,6 +355,7 @@ export const tasks: TelemetryTask[] = [
354355
const response = await search({
355356
index: [indices.transaction],
356357
body: {
358+
timeout,
357359
query: {
358360
bool: {
359361
filter: [{ range: { '@timestamp': { gte: 'now-1d' } } }],
@@ -1031,8 +1033,9 @@ export const tasks: TelemetryTask[] = [
10311033
},
10321034
{
10331035
name: 'cardinality',
1034-
executor: async ({ search }) => {
1036+
executor: async ({ indices, search }) => {
10351037
const allAgentsCardinalityResponse = await search({
1038+
index: [indices.transaction],
10361039
body: {
10371040
size: 0,
10381041
timeout,
@@ -1057,6 +1060,7 @@ export const tasks: TelemetryTask[] = [
10571060
});
10581061

10591062
const rumAgentCardinalityResponse = await search({
1063+
index: [indices.transaction],
10601064
body: {
10611065
size: 0,
10621066
timeout,

0 commit comments

Comments
 (0)