Skip to content

Commit

Permalink
[APM] Use force_synthetic_source in API tests (#144300)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Nov 1, 2022
1 parent 807b782 commit 1acc9a4
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 34 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions x-pack/plugins/apm/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const configSchema = schema.object({
sourcemap: schema.string({ defaultValue: 'apm-*' }),
onboarding: schema.string({ defaultValue: 'apm-*' }),
}),
forceSyntheticSource: schema.boolean({ defaultValue: false }),
});

// plugin config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('APMEventClient', () => {
indices: {} as any,
options: {
includeFrozen: false,
forceSyntheticSource: false,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface APMEventClientConfig {
indices: ApmIndicesConfig;
options: {
includeFrozen: boolean;
forceSyntheticSource: boolean;
};
}

Expand All @@ -89,13 +90,15 @@ export class APMEventClient {
private readonly request: KibanaRequest;
private readonly indices: ApmIndicesConfig;
private readonly includeFrozen: boolean;
private readonly forceSyntheticSource: boolean;

constructor(config: APMEventClientConfig) {
this.esClient = config.esClient;
this.debug = config.debug;
this.request = config.request;
this.indices = config.indices;
this.includeFrozen = config.options.includeFrozen;
this.forceSyntheticSource = config.options.forceSyntheticSource;
}

private callAsyncWithDebug<T extends { body: any }>({
Expand Down Expand Up @@ -149,11 +152,18 @@ export class APMEventClient {
this.indices
);

const forceSyntheticSourceForThisRequest =
this.forceSyntheticSource &&
params.apm.events.includes(ProcessorEvent.metric);

const searchParams = {
...withProcessorEventFilter,
...(this.includeFrozen ? { ignore_throttled: false } : {}),
ignore_unavailable: true,
preference: 'any',
...(forceSyntheticSourceForThisRequest
? { force_synthetic_source: true }
: {}),
};

return this.callAsyncWithDebug({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export async function getApmEventClient({
debug: params.query._inspect,
request,
indices,
options: { includeFrozen },
options: {
includeFrozen,
forceSyntheticSource: config.forceSyntheticSource,
},
});
});
}
1 change: 1 addition & 0 deletions x-pack/plugins/apm/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export class APMPlugin
indices,
options: {
includeFrozen,
forceSyntheticSource: currentConfig.forceSyntheticSource,
},
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7196,10 +7196,6 @@
"handled": {
"type": "boolean"
},
"message": {
"norms": false,
"type": "text"
},
"module": {
"ignore_above": 1024,
"type": "keyword"
Expand Down Expand Up @@ -7232,20 +7228,12 @@
"ignore_above": 1024,
"type": "keyword"
},
"message": {
"norms": false,
"type": "text"
},
"param_message": {
"ignore_above": 1024,
"type": "keyword"
}
}
},
"message": {
"norms": false,
"type": "text"
},
"stack_trace": {
"fields": {
"text": {
Expand Down Expand Up @@ -8460,10 +8448,6 @@
}
}
},
"message": {
"norms": false,
"type": "text"
},
"metricset": {
"properties": {
"name": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,6 @@
"handled": {
"type": "boolean"
},
"message": {
"norms": false,
"type": "text"
},
"module": {
"ignore_above": 1024,
"type": "keyword"
Expand Down Expand Up @@ -496,20 +492,12 @@
"ignore_above": 1024,
"type": "keyword"
},
"message": {
"norms": false,
"type": "text"
},
"param_message": {
"ignore_above": 1024,
"type": "keyword"
}
}
},
"message": {
"norms": false,
"type": "text"
},
"type": {
"ignore_above": 1024,
"type": "keyword"
Expand Down Expand Up @@ -1158,10 +1146,6 @@
}
}
},
"message": {
"norms": false,
"type": "text"
},
"network": {
"properties": {
"application": {
Expand Down Expand Up @@ -17630,4 +17614,4 @@
}
}
}
}
}
7 changes: 7 additions & 0 deletions x-pack/test/apm_api_integration/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ import { createTestConfig, CreateTestConfig } from '../common/config';
const apmFtrConfigs = {
basic: {
license: 'basic' as const,
kibanaConfig: {
'xpack.apm.forceSyntheticSource': 'true',
},
},
trial: {
license: 'trial' as const,
kibanaConfig: {
'xpack.apm.forceSyntheticSource': 'true',
},
},
rules: {
license: 'trial' as const,
kibanaConfig: {
'xpack.ruleRegistry.write.enabled': 'true',
'xpack.apm.forceSyntheticSource': 'true',
},
},
};
Expand Down

0 comments on commit 1acc9a4

Please sign in to comment.