From 74ef540e42d11ad469d6ff3a7ee149e6a61d5f32 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Thu, 3 Dec 2020 09:25:40 -0800 Subject: [PATCH] [CI] Enables APM collection (#81731) Signed-off-by: Tyler Smalley --- packages/kbn-apm-config-loader/src/config.ts | 14 ++++++++++---- vars/kibanaPipeline.groovy | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/kbn-apm-config-loader/src/config.ts b/packages/kbn-apm-config-loader/src/config.ts index a611e205ec83a..6e5a830d04b17 100644 --- a/packages/kbn-apm-config-loader/src/config.ts +++ b/packages/kbn-apm-config-loader/src/config.ts @@ -27,22 +27,27 @@ import { ApmAgentConfig } from './types'; const getDefaultConfig = (isDistributable: boolean): ApmAgentConfig => { // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html + return { - active: process.env.ELASTIC_APM_ACTIVE || false, + active: process.env.ELASTIC_APM_ACTIVE === 'true' || false, environment: process.env.ELASTIC_APM_ENVIRONMENT || process.env.NODE_ENV || 'development', - serverUrl: 'https://b1e3b4b4233e44cdad468c127d0af8d8.apm.europe-west1.gcp.cloud.es.io:443', + serverUrl: 'https://38b80fbd79fb4c91bae06b4642d4d093.apm.us-east-1.aws.cloud.es.io', // The secretToken below is intended to be hardcoded in this file even though // it makes it public. This is not a security/privacy issue. Normally we'd // instead disable the need for a secretToken in the APM Server config where // the data is transmitted to, but due to how it's being hosted, it's easier, // for now, to simply leave it in. - secretToken: '2OyjjaI6RVkzx2O5CV', + secretToken: 'ZQHYvrmXEx04ozge8F', logUncaughtExceptions: true, globalLabels: {}, centralConfig: false, + metricsInterval: isDistributable ? '120s' : '30s', + transactionSampleRate: process.env.ELASTIC_APM_TRANSACTION_SAMPLE_RATE + ? parseFloat(process.env.ELASTIC_APM_TRANSACTION_SAMPLE_RATE) + : 1.0, // Can be performance intensive, disabling by default breakdownMetrics: isDistributable ? false : true, @@ -150,8 +155,9 @@ export class ApmConfiguration { globalLabels: { branch: process.env.ghprbSourceBranch || '', targetBranch: process.env.ghprbTargetBranch || '', - ciJobName: process.env.JOB_NAME || '', ciBuildNumber: process.env.BUILD_NUMBER || '', + isPr: process.env.GITHUB_PR_NUMBER ? true : false, + prId: process.env.GITHUB_PR_NUMBER || '', }, }; } diff --git a/vars/kibanaPipeline.groovy b/vars/kibanaPipeline.groovy index 0051293704717..7991dd3252153 100644 --- a/vars/kibanaPipeline.groovy +++ b/vars/kibanaPipeline.groovy @@ -89,6 +89,7 @@ def withFunctionalTestEnv(List additionalEnvs = [], Closure closure) { def esTransportPort = "61${parallelId}3" def fleetPackageRegistryPort = "61${parallelId}4" def alertingProxyPort = "61${parallelId}5" + def apmActive = githubPr.isPr() ? "false" : "true" withEnv([ "CI_GROUP=${parallelId}", @@ -101,7 +102,9 @@ def withFunctionalTestEnv(List additionalEnvs = [], Closure closure) { "TEST_ES_TRANSPORT_PORT=${esTransportPort}", "KBN_NP_PLUGINS_BUILT=true", "FLEET_PACKAGE_REGISTRY_PORT=${fleetPackageRegistryPort}", - "ALERTING_PROXY_PORT=${alertingProxyPort}" + "ALERTING_PROXY_PORT=${alertingProxyPort}", + "ELASTIC_APM_ACTIVE=${apmActive}", + "ELASTIC_APM_TRANSACTION_SAMPLE_RATE=0.1", ] + additionalEnvs) { closure() }