Skip to content

Commit

Permalink
[KP] instrument platform server-side code with apm agent (elastic#70919)
Browse files Browse the repository at this point in the history
* instrument platform server-side code with apm agent: setup, start lifecycles and SO migration

* add span type

* span should have name: saved_objects.migration

* remove migration reports

* put migration span back
  • Loading branch information
mshustov committed Oct 1, 2020
1 parent 7ce4b6a commit 12667d9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

import apm from 'elastic-apm-node';
import { config as pathConfig } from '@kbn/utils';
import { mapToObject } from '@kbn/std';
import { ConfigService, Env, RawConfigurationProvider, coreDeprecationProvider } from './config';
Expand Down Expand Up @@ -106,6 +106,7 @@ export class Server {

public async setup() {
this.log.debug('setting up server');
const setupTransaction = apm.startTransaction('server_setup', 'kibana_platform');

const environmentSetup = await this.environment.setup();

Expand Down Expand Up @@ -207,20 +208,25 @@ export class Server {
this.registerCoreContext(coreSetup);
this.coreApp.setup(coreSetup);

setupTransaction?.end();
return coreSetup;
}

public async start() {
this.log.debug('starting server');
const startTransaction = apm.startTransaction('server_start', 'kibana_platform');

const auditTrailStart = this.auditTrail.start();

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();
Expand Down Expand Up @@ -248,6 +254,7 @@ export class Server {

await this.http.start();

startTransaction?.end();
return this.coreStart;
}

Expand Down

0 comments on commit 12667d9

Please sign in to comment.