Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ci/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

/* eslint-disable no-console */
const tracer = require('../packages/dd-trace')
const { isTrue, isFalse } = require('../packages/dd-trace/src/util')
const { isTrue } = require('../packages/dd-trace/src/util')
const log = require('../packages/dd-trace/src/log')
const { getEnvironmentVariable } = require('../packages/dd-trace/src/config-helper')
const getConfig = require('../packages/dd-trace/src/config')
const config = getConfig()

const PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm']
const DEFAULT_FLUSH_INTERVAL = 5000
Expand All @@ -24,6 +26,8 @@ function isPackageManager () {
}

function detectTestWorkerType () {
// [I think] these calls to getEnvironmentVariable should stay as-is, because they are specifically looking for
// presence of environment variables to detect the test worker type.
if (getEnvironmentVariable('JEST_WORKER_ID')) return 'jest'
if (getEnvironmentVariable('CUCUMBER_WORKER_ID')) return 'cucumber'
if (getEnvironmentVariable('MOCHA_WORKER_ID')) return 'mocha'
Expand All @@ -43,7 +47,7 @@ const baseOptions = {
flushInterval: isJestWorker ? JEST_FLUSH_INTERVAL : DEFAULT_FLUSH_INTERVAL
}

let shouldInit = !isFalse(getEnvironmentVariable('DD_CIVISIBILITY_ENABLED'))
let shouldInit = config.isCiVisibilityEnabled()
const isAgentlessEnabled = isTrue(getEnvironmentVariable('DD_CIVISIBILITY_AGENTLESS_ENABLED'))

if (!isTestWorker && isPackageManager()) {
Expand Down
8 changes: 8 additions & 0 deletions packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ class Config {
DD_APPSEC_RASP_COLLECT_REQUEST_BODY,
DD_APPSEC_TRACE_RATE_LIMIT,
DD_APPSEC_WAF_TIMEOUT,
DD_CIVISIBILITY_ENABLED,
DD_CRASHTRACKING_ENABLED,
DD_CODE_ORIGIN_FOR_SPANS_ENABLED,
DD_CODE_ORIGIN_FOR_SPANS_EXPERIMENTAL_EXIT_SPANS_ENABLED,
Expand Down Expand Up @@ -653,6 +654,7 @@ class Config {
unprocessedTarget['appsec.stackTrace.maxStackTraces'] = DD_APPSEC_MAX_STACK_TRACES
target['appsec.wafTimeout'] = maybeInt(DD_APPSEC_WAF_TIMEOUT)
unprocessedTarget['appsec.wafTimeout'] = DD_APPSEC_WAF_TIMEOUT
this.#setBoolean(target, 'ciVisibility.enabled', DD_CIVISIBILITY_ENABLED)
target.baggageMaxBytes = DD_TRACE_BAGGAGE_MAX_BYTES
target.baggageMaxItems = DD_TRACE_BAGGAGE_MAX_ITEMS
target.baggageTagKeys = DD_TRACE_BAGGAGE_TAG_KEYS
Expand Down Expand Up @@ -1040,6 +1042,7 @@ class Config {
this.#setBoolean(opts, 'iast.stackTrace.enabled', options.iast?.stackTrace?.enabled)
this.#setString(opts, 'iast.telemetryVerbosity', options.iast && options.iast.telemetryVerbosity)
this.#setBoolean(opts, 'isCiVisibility', options.isCiVisibility)
this.#setBoolean(opts, 'ciVisibility.enabled', options.ciVisibility?.enabled)
this.#setBoolean(opts, 'legacyBaggageEnabled', options.legacyBaggageEnabled)
this.#setBoolean(opts, 'llmobs.agentlessEnabled', options.llmobs?.agentlessEnabled)
this.#setString(opts, 'llmobs.mlApp', options.llmobs?.mlApp)
Expand Down Expand Up @@ -1104,6 +1107,11 @@ class Config {
}
}

isCiVisibilityEnabled () {
return this.ciVisibility.enabled
}

// Is this the same as IsCiVisibilityEnabled?
#isCiVisibility () {
return this.#optionsArg.isCiVisibility ?? this.#defaults.isCiVisibility
}
Expand Down
1 change: 1 addition & 0 deletions packages/dd-trace/src/config_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ module.exports = {
injectForce: null,
isAzureFunction: false,
isCiVisibility: false,
'ciVisibility.enabled': true,
isEarlyFlakeDetectionEnabled: false,
isFlakyTestRetriesEnabled: false,
flakyTestRetriesCount: 5,
Expand Down
Loading