Skip to content

Commit

Permalink
Updates APM defaults and CI settings (#117749) (#119553)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Tyler Smalley <[email protected]>
  • Loading branch information
kibanamachine and Tyler Smalley authored Nov 24, 2021
1 parent 7087317 commit 419c311
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .buildkite/scripts/common/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-apm-config-loader/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 7 additions & 5 deletions packages/kbn-apm-config-loader/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}
`);
});
Expand Down
26 changes: 15 additions & 11 deletions packages/kbn-apm-config-loader/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 || '',
},
};
}
Expand Down

0 comments on commit 419c311

Please sign in to comment.