mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
[SUPT] fix apm reporting (#135071)
This commit is contained in:
parent
705e516701
commit
61b5349d95
2 changed files with 55 additions and 9 deletions
|
@ -15,6 +15,21 @@ node scripts/es snapshot&
|
||||||
|
|
||||||
esPid=$!
|
esPid=$!
|
||||||
|
|
||||||
|
# unset env vars defined in other parts of CI for automatic APM collection of
|
||||||
|
# Kibana. We manage APM config in our FTR config and performance service, and
|
||||||
|
# APM treats config in the ENV with a very high precedence.
|
||||||
|
unset ELASTIC_APM_ENVIRONMENT
|
||||||
|
unset ELASTIC_APM_TRANSACTION_SAMPLE_RATE
|
||||||
|
unset ELASTIC_APM_SERVER_URL
|
||||||
|
unset ELASTIC_APM_SECRET_TOKEN
|
||||||
|
unset ELASTIC_APM_ACTIVE
|
||||||
|
unset ELASTIC_APM_CONTEXT_PROPAGATION_ONLY
|
||||||
|
unset ELASTIC_APM_ACTIVE
|
||||||
|
unset ELASTIC_APM_SERVER_URL
|
||||||
|
unset ELASTIC_APM_SECRET_TOKEN
|
||||||
|
unset ELASTIC_APM_GLOBAL_LABELS
|
||||||
|
|
||||||
|
|
||||||
export TEST_ES_URL=http://elastic:changeme@localhost:9200
|
export TEST_ES_URL=http://elastic:changeme@localhost:9200
|
||||||
export TEST_ES_DISABLE_STARTUP=true
|
export TEST_ES_DISABLE_STARTUP=true
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
import Url from 'url';
|
import Url from 'url';
|
||||||
import { inspect } from 'util';
|
import { inspect } from 'util';
|
||||||
|
import { setTimeout } from 'timers/promises';
|
||||||
import apm, { Span, Transaction } from 'elastic-apm-node';
|
import apm, { Span, Transaction } from 'elastic-apm-node';
|
||||||
import playwright, { ChromiumBrowser, Page, BrowserContext, CDPSession } from 'playwright';
|
import playwright, { ChromiumBrowser, Page, BrowserContext, CDPSession } from 'playwright';
|
||||||
import { FtrService, FtrProviderContext } from '../ftr_provider_context';
|
import { FtrService, FtrProviderContext } from '../ftr_provider_context';
|
||||||
|
@ -35,14 +36,45 @@ export class PerformanceTestingService extends FtrService {
|
||||||
ctx.getService('lifecycle').beforeTests.add(() => {
|
ctx.getService('lifecycle').beforeTests.add(() => {
|
||||||
apm.start({
|
apm.start({
|
||||||
serviceName: 'functional test runner',
|
serviceName: 'functional test runner',
|
||||||
|
environment: process.env.CI ? 'ci' : 'development',
|
||||||
|
active: this.config.get(`kbnTestServer.env`).ELASTIC_APM_ACTIVE !== 'false',
|
||||||
serverUrl: this.config.get(`kbnTestServer.env`).ELASTIC_APM_SERVER_URL,
|
serverUrl: this.config.get(`kbnTestServer.env`).ELASTIC_APM_SERVER_URL,
|
||||||
secretToken: this.config.get(`kbnTestServer.env`).ELASTIC_APM_SECRET_TOKEN,
|
secretToken: this.config.get(`kbnTestServer.env`).ELASTIC_APM_SECRET_TOKEN,
|
||||||
globalLabels: this.config.get(`kbnTestServer.env`).ELASTIC_APM_GLOBAL_LABELS,
|
globalLabels: this.config.get(`kbnTestServer.env`).ELASTIC_APM_GLOBAL_LABELS,
|
||||||
|
transactionSampleRate:
|
||||||
|
this.config.get(`kbnTestServer.env`).ELASTIC_APM_TRANSACTION_SAMPLE_RATE,
|
||||||
|
logger: process.env.VERBOSE_APM_LOGGING
|
||||||
|
? {
|
||||||
|
warn(...args: any[]) {
|
||||||
|
console.log('APM WARN', ...args);
|
||||||
|
},
|
||||||
|
info(...args: any[]) {
|
||||||
|
console.log('APM INFO', ...args);
|
||||||
|
},
|
||||||
|
fatal(...args: any[]) {
|
||||||
|
console.log('APM FATAL', ...args);
|
||||||
|
},
|
||||||
|
error(...args: any[]) {
|
||||||
|
console.log('APM ERROR', ...args);
|
||||||
|
},
|
||||||
|
debug(...args: any[]) {
|
||||||
|
console.log('APM DEBUG', ...args);
|
||||||
|
},
|
||||||
|
trace(...args: any[]) {
|
||||||
|
console.log('APM TRACE', ...args);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.getService('lifecycle').cleanup.add(async () => {
|
ctx.getService('lifecycle').cleanup.add(async () => {
|
||||||
await this.shutdownBrowser();
|
await this.shutdownBrowser();
|
||||||
|
await new Promise<void>((resolve) => apm.flush(() => resolve()));
|
||||||
|
// wait for the HTTP request that apm.flush() starts, which we
|
||||||
|
// can't track but hope is complete within 3 seconds
|
||||||
|
// https://github.com/elastic/apm-agent-nodejs/issues/2088
|
||||||
|
await setTimeout(3000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +205,6 @@ export class PerformanceTestingService extends FtrService {
|
||||||
|
|
||||||
private async tearDown(page: Page, client: CDPSession, context: BrowserContext) {
|
private async tearDown(page: Page, client: CDPSession, context: BrowserContext) {
|
||||||
if (page) {
|
if (page) {
|
||||||
apm.flush();
|
|
||||||
await client.detach();
|
await client.detach();
|
||||||
await page.close();
|
await page.close();
|
||||||
await context.close();
|
await context.close();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue