@@ -26,32 +26,26 @@ import { readFileSync } from 'fs';
2626import { ApmAgentConfig } from './types' ;
2727
2828const getDefaultConfig = ( isDistributable : boolean ) : ApmAgentConfig => {
29- if ( isDistributable ) {
30- return {
31- active : false ,
32- globalLabels : { } ,
33- // Do not use a centralized controlled config
34- centralConfig : false ,
35- // Capture all exceptions that are not caught
36- logUncaughtExceptions : true ,
37- // Can be performance intensive, disabling by default
38- breakdownMetrics : false ,
39- } ;
40- }
41-
29+ // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html
4230 return {
43- active : false ,
44- serverUrl : 'https://f1542b814f674090afd914960583265f.apm.us-central1.gcp.cloud.es.io:443' ,
31+ active : process . env . ELASTIC_APM_ACTIVE || false ,
32+ environment : process . env . ELASTIC_APM_ENVIRONMENT || process . env . NODE_ENV || 'development' ,
33+
34+ serverUrl : 'https://b1e3b4b4233e44cdad468c127d0af8d8.apm.europe-west1.gcp.cloud.es.io:443' ,
35+
4536 // The secretToken below is intended to be hardcoded in this file even though
4637 // it makes it public. This is not a security/privacy issue. Normally we'd
4738 // instead disable the need for a secretToken in the APM Server config where
4839 // the data is transmitted to, but due to how it's being hosted, it's easier,
4940 // for now, to simply leave it in.
50- secretToken : 'R0Gjg46pE9K9wGestd' ,
41+ secretToken : '2OyjjaI6RVkzx2O5CV' ,
42+
43+ logUncaughtExceptions : true ,
5144 globalLabels : { } ,
52- breakdownMetrics : true ,
5345 centralConfig : false ,
54- logUncaughtExceptions : true ,
46+
47+ // Can be performance intensive, disabling by default
48+ breakdownMetrics : isDistributable ? false : true ,
5549 } ;
5650} ;
5751
@@ -84,7 +78,8 @@ export class ApmConfiguration {
8478 getDefaultConfig ( this . isDistributable ) ,
8579 this . getConfigFromKibanaConfig ( ) ,
8680 this . getDevConfig ( ) ,
87- this . getDistConfig ( )
81+ this . getDistConfig ( ) ,
82+ this . getCIConfig ( )
8883 ) ;
8984
9085 const rev = this . getGitRev ( ) ;
@@ -146,6 +141,21 @@ export class ApmConfiguration {
146141 } ;
147142 }
148143
144+ private getCIConfig ( ) : ApmAgentConfig {
145+ if ( process . env . ELASTIC_APM_ENVIRONMENT !== 'ci' ) {
146+ return { } ;
147+ }
148+
149+ return {
150+ globalLabels : {
151+ branch : process . env . ghprbSourceBranch || '' ,
152+ targetBranch : process . env . ghprbTargetBranch || '' ,
153+ ciJobName : process . env . JOB_NAME || '' ,
154+ ciBuildNumber : process . env . BUILD_NUMBER || '' ,
155+ } ,
156+ } ;
157+ }
158+
149159 private getGitRev ( ) {
150160 if ( this . isDistributable ) {
151161 return this . pkgBuild . sha ;
0 commit comments