Updates APM defaults and CI settings (#117749) (#119552)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
Kibana Machine 2021-11-23 19:09:47 -05:00 committed by GitHub
parent 4a94a21812
commit e4b9fdb1ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 17 deletions

View file

@ -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

View file

@ -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(

View file

@ -95,8 +95,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,
@ -119,11 +120,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,
}
`);
});

View file

@ -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 = {
@ -23,28 +24,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 {
@ -222,10 +225,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 || '',
},
};
}