Skip to content

Commit 66b446b

Browse files
committed
Migrate some CI Vis calls to new Config getters
1 parent 3e68da8 commit 66b446b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

ci/init.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
/* eslint-disable no-console */
44
const tracer = require('../packages/dd-trace')
5-
const { isTrue, isFalse } = require('../packages/dd-trace/src/util')
65
const log = require('../packages/dd-trace/src/log')
76
const { getEnvironmentVariable } = require('../packages/dd-trace/src/config-helper')
7+
const { isCIVisibilityEnabled, isCiVisibilityAgentlessEnabled, getAPIKey } = require('../packages/dd-trace/src/config')
88

99
const PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm']
1010
const DEFAULT_FLUSH_INTERVAL = 5000
@@ -42,8 +42,8 @@ const baseOptions = {
4242
flushInterval: isJestWorker ? JEST_FLUSH_INTERVAL : DEFAULT_FLUSH_INTERVAL
4343
}
4444

45-
let shouldInit = !isFalse(getEnvironmentVariable('DD_CIVISIBILITY_ENABLED'))
46-
const isAgentlessEnabled = isTrue(getEnvironmentVariable('DD_CIVISIBILITY_AGENTLESS_ENABLED'))
45+
let shouldInit = isCIVisibilityEnabled()
46+
const isAgentlessEnabled = isCiVisibilityAgentlessEnabled()
4747

4848
if (!isTestWorker && isPackageManager()) {
4949
log.debug('dd-trace is not initialized in a package manager.')
@@ -57,7 +57,7 @@ if (isTestWorker) {
5757
}
5858
} else {
5959
if (isAgentlessEnabled) {
60-
if (getEnvironmentVariable('DD_API_KEY')) {
60+
if (getAPIKey()) {
6161
baseOptions.experimental = {
6262
exporter: 'datadog'
6363
}

packages/dd-trace/src/config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,17 @@ class Config {
14641464
}
14651465
}
14661466
}
1467+
1468+
isCIVisibilityEnabled () {
1469+
return this.isCiVisibility
1470+
}
1471+
1472+
isCiVisibilityAgentlessEnabled () {
1473+
return this.isCiVisibilityAgentless
1474+
}
1475+
1476+
getAPIKey () {
1477+
return this.apiKey
14671478
}
14681479

14691480
function handleOtel (tagString) {

0 commit comments

Comments
 (0)