Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Performance fix for 'cardinality' telemetry task #144061

Merged
merged 3 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ type ISavedObjectsClient = Pick<SavedObjectsClient, 'find'>;

type TelemetryTaskExecutor = (params: {
indices: ApmIndicesConfig;
search<TSearchRequest extends ESSearchRequest>(
search<
TSearchRequest extends ESSearchRequest & { index: string | string[] } & {
body: { timeout: string };
}
>(
params: TSearchRequest
): Promise<ESSearchResponse<unknown, TSearchRequest>>;
indicesStats(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ describe('data telemetry collection tasks', () => {
}
});

expect(await task?.executor({ search } as any)).toEqual({
expect(await task?.executor({ search, indices } as any)).toEqual({
cardinality: {
client: { geo: { country_iso_code: { rum: { '1d': 5 } } } },
transaction: { name: { all_agents: { '1d': 3 }, rum: { '1d': 1 } } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export const tasks: TelemetryTask[] = [
await search({
index: indices.transaction,
body: {
timeout,
query: {
bool: {
filter: [
Expand Down Expand Up @@ -355,6 +356,7 @@ export const tasks: TelemetryTask[] = [
const response = await search({
index: [indices.transaction],
body: {
timeout,
query: {
bool: {
filter: [{ range: { '@timestamp': { gte: 'now-1d' } } }],
Expand Down Expand Up @@ -1032,8 +1034,9 @@ export const tasks: TelemetryTask[] = [
},
{
name: 'cardinality',
executor: async ({ search }) => {
executor: async ({ indices, search }) => {
const allAgentsCardinalityResponse = await search({
index: [indices.transaction],
body: {
size: 0,
timeout,
Expand All @@ -1058,6 +1061,7 @@ export const tasks: TelemetryTask[] = [
});

const rumAgentCardinalityResponse = await search({
index: [indices.transaction],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should make index required

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a fix for that in the works, just waiting on @basepi's permission to push it to this PR. That will also close #143819

body: {
size: 0,
timeout,
Expand Down