diff --git a/.buildkite/scripts/common/env.sh b/.buildkite/scripts/common/env.sh index 0715b07fd58e8..45643d198df58 100755 --- a/.buildkite/scripts/common/env.sh +++ b/.buildkite/scripts/common/env.sh @@ -34,6 +34,8 @@ export TEST_BROWSER_HEADLESS=1 export ELASTIC_APM_ENVIRONMENT=ci export ELASTIC_APM_TRANSACTION_SAMPLE_RATE=0.1 +export ELASTIC_APM_SERVER_URL=https://kibana-ci-apm.apm.us-central1.gcp.cloud.es.io +export ELASTIC_APM_SECRET_TOKEN=7YKhoXsO4MzjhXjx2c if is_pr; then if [[ "${GITHUB_PR_LABELS:-}" == *"ci:collect-apm"* ]]; then diff --git a/packages/kbn-apm-config-loader/BUILD.bazel b/packages/kbn-apm-config-loader/BUILD.bazel index 8fb513a746ec3..731876d5b550c 100644 --- a/packages/kbn-apm-config-loader/BUILD.bazel +++ b/packages/kbn-apm-config-loader/BUILD.bazel @@ -36,11 +36,12 @@ RUNTIME_DEPS = [ TYPES_DEPS = [ "//packages/elastic-safer-lodash-set", "//packages/kbn-utils", - "@npm//elastic-apm-node", + "@npm//@elastic/apm-rum", "@npm//@types/jest", "@npm//@types/js-yaml", "@npm//@types/lodash", "@npm//@types/node", + "@npm//elastic-apm-node", ] jsts_transpiler( diff --git a/packages/kbn-apm-config-loader/src/config.test.ts b/packages/kbn-apm-config-loader/src/config.test.ts index 60d773e3a420b..8506572c2c00c 100644 --- a/packages/kbn-apm-config-loader/src/config.test.ts +++ b/packages/kbn-apm-config-loader/src/config.test.ts @@ -94,8 +94,9 @@ describe('ApmConfiguration', () => { "globalLabels": Object {}, "logUncaughtExceptions": true, "metricsInterval": "30s", - "secretToken": "7YKhoXsO4MzjhXjx2c", - "serverUrl": "https://kibana-ci-apm.apm.us-central1.gcp.cloud.es.io", + "propagateTracestate": true, + "secretToken": "JpBCcOQxN81D5yucs2", + "serverUrl": "https://kibana-cloud-apm.apm.us-east-1.aws.found.io", "serviceName": "serviceName", "serviceVersion": "8.0.0", "transactionSampleRate": 1, @@ -117,11 +118,12 @@ describe('ApmConfiguration', () => { }, "logUncaughtExceptions": true, "metricsInterval": "120s", - "secretToken": "7YKhoXsO4MzjhXjx2c", - "serverUrl": "https://kibana-ci-apm.apm.us-central1.gcp.cloud.es.io", + "propagateTracestate": true, + "secretToken": "JpBCcOQxN81D5yucs2", + "serverUrl": "https://kibana-cloud-apm.apm.us-east-1.aws.found.io", "serviceName": "serviceName", "serviceVersion": "8.0.0", - "transactionSampleRate": 1, + "transactionSampleRate": 0.1, } `); }); diff --git a/packages/kbn-apm-config-loader/src/config.ts b/packages/kbn-apm-config-loader/src/config.ts index 999e4ce3a6805..b3e8503cf5ea0 100644 --- a/packages/kbn-apm-config-loader/src/config.ts +++ b/packages/kbn-apm-config-loader/src/config.ts @@ -13,6 +13,7 @@ import { execSync } from 'child_process'; import { getDataPath } from '@kbn/utils'; import { readFileSync } from 'fs'; import type { AgentConfigOptions } from 'elastic-apm-node'; +import type { AgentConfigOptions as RUMAgentConfigOptions } from '@elastic/apm-rum'; // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html const DEFAULT_CONFIG: AgentConfigOptions = { @@ -22,28 +23,30 @@ const DEFAULT_CONFIG: AgentConfigOptions = { globalLabels: {}, }; -const CENTRALIZED_SERVICE_BASE_CONFIG: AgentConfigOptions = { - serverUrl: 'https://kibana-ci-apm.apm.us-central1.gcp.cloud.es.io', +const CENTRALIZED_SERVICE_BASE_CONFIG: AgentConfigOptions | RUMAgentConfigOptions = { + serverUrl: 'https://kibana-cloud-apm.apm.us-east-1.aws.found.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: '7YKhoXsO4MzjhXjx2c', + secretToken: 'JpBCcOQxN81D5yucs2', + breakdownMetrics: true, + captureSpanStackTraces: false, centralConfig: false, metricsInterval: '30s', - captureSpanStackTraces: false, + propagateTracestate: true, transactionSampleRate: 1.0, - breakdownMetrics: true, }; const CENTRALIZED_SERVICE_DIST_CONFIG: AgentConfigOptions = { - metricsInterval: '120s', + breakdownMetrics: false, captureBody: 'off', captureHeaders: false, - breakdownMetrics: false, + metricsInterval: '120s', + transactionSampleRate: 0.1, }; export class ApmConfiguration { @@ -215,10 +218,11 @@ export class ApmConfiguration { return { globalLabels: { branch: process.env.GIT_BRANCH || '', - targetBranch: process.env.PR_TARGET_BRANCH || '', - ciBuildNumber: process.env.BUILD_NUMBER || '', - isPr: process.env.GITHUB_PR_NUMBER ? true : false, - prId: process.env.GITHUB_PR_NUMBER || '', + targetBranch: process.env.GITHUB_PR_TARGET_BRANCH || '', + ciBuildNumber: process.env.BUILDKITE_BUILD_NUMBER || '', + ciBuildId: process.env.BUILDKITE_BUILD_ID || '', + isPr: process.env.BUILDKITE_PULL_REQUEST ? true : false, + prId: process.env.BUILDKITE_PULL_REQUEST || '', }, }; }