From e64666534a7a2458553f2a00d78563d228269b81 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 7 Jul 2020 09:01:41 +0200 Subject: [PATCH 1/5] instrument platform server-side code with apm agent: setup, start lifecycles and SO migration --- .../server/saved_objects/saved_objects_service.ts | 5 +++++ src/core/server/server.ts | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/core/server/saved_objects/saved_objects_service.ts b/src/core/server/saved_objects/saved_objects_service.ts index c2d4f49d7ee2..b5ef90ab3068 100644 --- a/src/core/server/saved_objects/saved_objects_service.ts +++ b/src/core/server/saved_objects/saved_objects_service.ts @@ -17,6 +17,7 @@ * under the License. */ +import apm from 'elastic-apm-node'; import { Subject, Observable } from 'rxjs'; import { first, filter, take, switchMap } from 'rxjs/operators'; import { CoreService } from '../../types'; @@ -431,7 +432,11 @@ export class SavedObjectsService ).toPromise(); this.logger.info('Starting saved objects migrations'); + const migrationSpan = apm.startSpan('saved_objects.migration'); await migrator.runMigrations(); + if (migrationSpan) { + migrationSpan.end(); + } } const createRepository = (callCluster: LegacyAPICaller, includedHiddenTypes: string[] = []) => { diff --git a/src/core/server/server.ts b/src/core/server/server.ts index dc37b77c57c9..4e102ed9f473 100644 --- a/src/core/server/server.ts +++ b/src/core/server/server.ts @@ -18,6 +18,7 @@ */ import { Type } from '@kbn/config-schema'; +import apm from 'elastic-apm-node'; import { ConfigService, @@ -110,6 +111,7 @@ export class Server { public async setup() { this.log.debug('setting up server'); + const setupTransaction = apm.startTransaction('server_setup', 'kibana_platform'); // Discover any plugins before continuing. This allows other systems to utilize the plugin dependency graph. const { pluginTree, uiPlugins } = await this.plugins.discover(); @@ -198,11 +200,16 @@ export class Server { this.registerCoreContext(coreSetup); this.coreApp.setup(coreSetup); + if (setupTransaction) { + setupTransaction.end(); + } return coreSetup; } public async start() { this.log.debug('starting server'); + const startTransaction = apm.startTransaction('server_start', 'kibana_platform'); + const elasticsearchStart = await this.elasticsearch.start(); const savedObjectsStart = await this.savedObjects.start({ elasticsearch: elasticsearchStart, @@ -238,6 +245,10 @@ export class Server { legacy: this.legacy, }); + if (startTransaction) { + startTransaction.end(); + } + return this.coreStart; } From cd952b233e588c396852aa53e854fab549dcffe4 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 8 Jul 2020 09:28:48 +0200 Subject: [PATCH 2/5] add span type --- src/core/server/saved_objects/saved_objects_service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/saved_objects/saved_objects_service.ts b/src/core/server/saved_objects/saved_objects_service.ts index b5ef90ab3068..215764257e37 100644 --- a/src/core/server/saved_objects/saved_objects_service.ts +++ b/src/core/server/saved_objects/saved_objects_service.ts @@ -432,7 +432,7 @@ export class SavedObjectsService ).toPromise(); this.logger.info('Starting saved objects migrations'); - const migrationSpan = apm.startSpan('saved_objects.migration'); + const migrationSpan = apm.startSpan('saved_objects', 'migration'); await migrator.runMigrations(); if (migrationSpan) { migrationSpan.end(); From 8be0c038f8d6e48109e649174d43e48032dfcdd6 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 8 Jul 2020 13:43:59 +0200 Subject: [PATCH 3/5] span should have name: saved_objects.migration --- src/core/server/saved_objects/saved_objects_service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/saved_objects/saved_objects_service.ts b/src/core/server/saved_objects/saved_objects_service.ts index 215764257e37..560ab9342bfa 100644 --- a/src/core/server/saved_objects/saved_objects_service.ts +++ b/src/core/server/saved_objects/saved_objects_service.ts @@ -432,7 +432,7 @@ export class SavedObjectsService ).toPromise(); this.logger.info('Starting saved objects migrations'); - const migrationSpan = apm.startSpan('saved_objects', 'migration'); + const migrationSpan = apm.startSpan('saved_objects.migration', 'migration'); await migrator.runMigrations(); if (migrationSpan) { migrationSpan.end(); From 892a5a9f8f6fe3b1f4267d6af8afa4005777abe4 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 30 Sep 2020 20:48:34 +0300 Subject: [PATCH 4/5] remove migration reports --- src/core/server/saved_objects/saved_objects_service.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/core/server/saved_objects/saved_objects_service.ts b/src/core/server/saved_objects/saved_objects_service.ts index c9c0295491dc..5cc59d55a254 100644 --- a/src/core/server/saved_objects/saved_objects_service.ts +++ b/src/core/server/saved_objects/saved_objects_service.ts @@ -17,7 +17,6 @@ * under the License. */ -import apm from 'elastic-apm-node'; import { Subject, Observable } from 'rxjs'; import { first, filter, take, switchMap } from 'rxjs/operators'; import { CoreService } from '../../types'; @@ -403,11 +402,7 @@ export class SavedObjectsService ).toPromise(); this.logger.info('Starting saved objects migrations'); - const migrationSpan = apm.startSpan('saved_objects.migration', 'migration'); await migrator.runMigrations(); - if (migrationSpan) { - migrationSpan.end(); - } } const createRepository = ( From 32c8fd27eb11d10efcfb942614dee3edffcbe260 Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Thu, 1 Oct 2020 12:29:10 +0300 Subject: [PATCH 5/5] put migration span back --- src/core/server/server.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/core/server/server.ts b/src/core/server/server.ts index d3a668e6326f..4e5a7a328bed 100644 --- a/src/core/server/server.ts +++ b/src/core/server/server.ts @@ -208,9 +208,7 @@ export class Server { this.registerCoreContext(coreSetup); this.coreApp.setup(coreSetup); - if (setupTransaction) { - setupTransaction.end(); - } + setupTransaction?.end(); return coreSetup; } @@ -223,11 +221,12 @@ export class Server { const elasticsearchStart = await this.elasticsearch.start({ auditTrail: auditTrailStart, }); - + const soStartSpan = startTransaction?.startSpan('saved_objects.migration', 'migration'); const savedObjectsStart = await this.savedObjects.start({ elasticsearch: elasticsearchStart, pluginsInitialized: this.#pluginsInitialized, }); + soStartSpan?.end(); const capabilitiesStart = this.capabilities.start(); const uiSettingsStart = await this.uiSettings.start(); const metricsStart = await this.metrics.start(); @@ -255,9 +254,7 @@ export class Server { await this.http.start(); - if (startTransaction) { - startTransaction.end(); - } + startTransaction?.end(); return this.coreStart; }