Skip to content

Commit

Permalink
Adds CI specific labels
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
  • Loading branch information
Tyler Smalley committed Oct 22, 2020
1 parent b26553a commit 55fe467
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions packages/kbn-apm-config-loader/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { ApmAgentConfig } from './types';

const getDefaultConfig = (isDistributable: boolean): ApmAgentConfig => {
// https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html
const baseConfig = {
return {
active: process.env.ELASTIC_APM_ACTIVE || false,
environment: process.env.ELASTIC_APM_ENVIRONMENT || process.env.NODE_ENV || 'development',

Expand All @@ -45,19 +45,8 @@ const getDefaultConfig = (isDistributable: boolean): ApmAgentConfig => {
centralConfig: false,

// Can be performance intensive, disabling by default
breakdownMetrics: false,
breakdownMetrics: isDistributable ? false : true,
};

if (!isDistributable) {
return {
...baseConfig,
...{
breakdownMetrics: true,
},
};
}

return baseConfig;
};

export class ApmConfiguration {
Expand Down Expand Up @@ -89,7 +78,8 @@ export class ApmConfiguration {
getDefaultConfig(this.isDistributable),
this.getConfigFromKibanaConfig(),
this.getDevConfig(),
this.getDistConfig()
this.getDistConfig(),
this.getCIConfig()
);

const rev = this.getGitRev();
Expand Down Expand Up @@ -151,6 +141,21 @@ export class ApmConfiguration {
};
}

private getCIConfig(): ApmAgentConfig {
if (process.env.ELASTIC_APM_ENVIRONMENT !== 'ci') {
return {};
}

return {
globalLabels: {
branchName: process.env.BRANCH_NAME || '',
targetBranch: process.env.ghprbTargetBranch || '',
ciJobName: process.env.JOB_NAME || '',
ciBuildNumber: process.env.BUILD_NUMBER || '',
},
};
}

private getGitRev() {
if (this.isDistributable) {
return this.pkgBuild.sha;
Expand Down

0 comments on commit 55fe467

Please sign in to comment.