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

[KP] instrument platform server-side code with apm agent #70919

Merged
merged 8 commits into from
Oct 1, 2020
5 changes: 5 additions & 0 deletions src/core/server/saved_objects/saved_objects_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -431,7 +432,11 @@ export class SavedObjectsService
).toPromise();

this.logger.info('Starting saved objects migrations');
const migrationSpan = apm.startSpan('saved_objects.migration');
mshustov marked this conversation as resolved.
Show resolved Hide resolved
await migrator.runMigrations();
if (migrationSpan) {
migrationSpan.end();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: migrationSpan?.end(); (multiple occurences)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for this, we need to turn off eslint/no-unused-expressions and use @typescript-eslint/no-unused-expressions instead.
typescript-eslint/typescript-eslint#1220

}

const createRepository = (callCluster: LegacyAPICaller, includedHiddenTypes: string[] = []) => {
Expand Down
11 changes: 11 additions & 0 deletions src/core/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { Type } from '@kbn/config-schema';
import apm from 'elastic-apm-node';

import {
ConfigService,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -238,6 +245,10 @@ export class Server {
legacy: this.legacy,
});

if (startTransaction) {
startTransaction.end();
}

return this.coreStart;
}

Expand Down