dd-trace 5.73.0 → 5.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +2 -0
- package/index.d.ts +39 -7
- package/loader-hook.mjs +52 -1
- package/package.json +8 -16
- package/packages/datadog-core/src/utils/src/set.js +5 -1
- package/packages/datadog-esbuild/index.js +105 -36
- package/packages/datadog-esbuild/src/utils.js +198 -0
- package/packages/datadog-instrumentations/src/cookie-parser.js +0 -2
- package/packages/datadog-instrumentations/src/cucumber.js +2 -2
- package/packages/datadog-instrumentations/src/express.js +82 -0
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +238 -0
- package/packages/datadog-instrumentations/src/jest.js +2 -1
- package/packages/datadog-instrumentations/src/mariadb.js +9 -7
- package/packages/datadog-instrumentations/src/playwright.js +226 -93
- package/packages/datadog-instrumentations/src/router.js +63 -6
- package/packages/datadog-instrumentations/src/vitest.js +44 -12
- package/packages/datadog-instrumentations/src/ws.js +3 -3
- package/packages/datadog-plugin-aws-sdk/src/base.js +0 -1
- package/packages/datadog-plugin-express/src/code_origin.js +2 -0
- package/packages/datadog-plugin-playwright/src/index.js +74 -31
- package/packages/datadog-plugin-ws/src/close.js +1 -1
- package/packages/datadog-shimmer/src/shimmer.js +2 -0
- package/packages/dd-trace/src/aiguard/sdk.js +25 -3
- package/packages/dd-trace/src/aiguard/tags.js +4 -1
- package/packages/dd-trace/src/config-helper.js +4 -1
- package/packages/dd-trace/src/config.js +599 -592
- package/packages/dd-trace/src/config_defaults.js +14 -12
- package/packages/dd-trace/src/plugins/util/ci.js +3 -2
- package/packages/dd-trace/src/plugins/util/stacktrace.js +16 -1
- package/packages/dd-trace/src/proxy.js +1 -1
- package/packages/dd-trace/src/supported-configurations.json +1 -0
- package/packages/dd-trace/src/telemetry/endpoints.js +27 -1
- package/packages/dd-trace/src/telemetry/index.js +16 -13
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +5 -3
- package/register.js +1 -11
- package/scripts/preinstall.js +3 -1
- package/version.js +2 -1
|
@@ -16,9 +16,10 @@ const telemetryMetrics = require('./telemetry/metrics')
|
|
|
16
16
|
const { isInServerlessEnvironment, getIsGCPFunction, getIsAzureFunction } = require('./serverless')
|
|
17
17
|
const { ORIGIN_KEY } = require('./constants')
|
|
18
18
|
const { appendRules } = require('./payload-tagging/config')
|
|
19
|
-
const { getEnvironmentVariable, getEnvironmentVariables } = require('./config-helper')
|
|
19
|
+
const { getEnvironmentVariable: getEnv, getEnvironmentVariables } = require('./config-helper')
|
|
20
20
|
const defaults = require('./config_defaults')
|
|
21
21
|
const path = require('path')
|
|
22
|
+
const { DD_MAJOR } = require('../../../version')
|
|
22
23
|
|
|
23
24
|
const tracerMetrics = telemetryMetrics.manager.namespace('tracers')
|
|
24
25
|
|
|
@@ -83,53 +84,49 @@ function getFromOtelSamplerMap (otelTracesSampler, otelTracesSamplerArg) {
|
|
|
83
84
|
return OTEL_TRACES_SAMPLER_MAPPING[otelTracesSampler]
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
87
|
+
/**
|
|
88
|
+
* Validate the type of an environment variable
|
|
89
|
+
* @param {string} envVar - The name of the environment variable
|
|
90
|
+
* @param {string} [value] - The value of the environment variable
|
|
91
|
+
* @returns {boolean} - True if the value is valid, false otherwise
|
|
92
|
+
*/
|
|
93
|
+
function isInvalidOtelEnvironmentVariable (envVar, value) {
|
|
94
|
+
// Skip validation if the value is undefined (it was not set as environment variable)
|
|
95
|
+
if (value === undefined) return false
|
|
99
96
|
|
|
100
|
-
function validateEnvVarType (envVar) {
|
|
101
|
-
const value = getEnvironmentVariable(envVar)
|
|
102
97
|
switch (envVar) {
|
|
103
98
|
case 'OTEL_LOG_LEVEL':
|
|
104
|
-
return VALID_LOG_LEVELS.has(value)
|
|
99
|
+
return !VALID_LOG_LEVELS.has(value)
|
|
105
100
|
case 'OTEL_PROPAGATORS':
|
|
106
101
|
case 'OTEL_RESOURCE_ATTRIBUTES':
|
|
107
102
|
case 'OTEL_SERVICE_NAME':
|
|
108
|
-
return typeof value
|
|
103
|
+
return typeof value !== 'string'
|
|
109
104
|
case 'OTEL_TRACES_SAMPLER':
|
|
110
|
-
return getFromOtelSamplerMap(value,
|
|
105
|
+
return getFromOtelSamplerMap(value, getEnv('OTEL_TRACES_SAMPLER_ARG')) === undefined
|
|
111
106
|
case 'OTEL_TRACES_SAMPLER_ARG':
|
|
112
|
-
return
|
|
107
|
+
return Number.isNaN(Number.parseFloat(value))
|
|
113
108
|
case 'OTEL_SDK_DISABLED':
|
|
114
|
-
return value.toLowerCase()
|
|
109
|
+
return value.toLowerCase() !== 'true' && value.toLowerCase() !== 'false'
|
|
115
110
|
case 'OTEL_TRACES_EXPORTER':
|
|
116
111
|
case 'OTEL_METRICS_EXPORTER':
|
|
117
112
|
case 'OTEL_LOGS_EXPORTER':
|
|
118
|
-
return value.toLowerCase()
|
|
113
|
+
return value.toLowerCase() !== 'none'
|
|
119
114
|
default:
|
|
120
|
-
return
|
|
115
|
+
return true
|
|
121
116
|
}
|
|
122
117
|
}
|
|
123
118
|
|
|
124
119
|
function checkIfBothOtelAndDdEnvVarSet () {
|
|
125
120
|
for (const [otelEnvVar, ddEnvVar] of Object.entries(otelDdEnvMapping)) {
|
|
126
|
-
|
|
121
|
+
const otelValue = getEnv(otelEnvVar)
|
|
122
|
+
|
|
123
|
+
if (ddEnvVar && getEnv(ddEnvVar) && otelValue) {
|
|
127
124
|
log.warn('both %s and %s environment variables are set', ddEnvVar, otelEnvVar)
|
|
128
125
|
getCounter('otel.env.hiding', ddEnvVar, otelEnvVar).inc()
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
if (
|
|
132
|
-
log.warn('unexpected value for %s environment variable', otelEnvVar)
|
|
128
|
+
if (isInvalidOtelEnvironmentVariable(otelEnvVar, otelValue)) {
|
|
129
|
+
log.warn('unexpected value %s for %s environment variable', otelValue, otelEnvVar)
|
|
133
130
|
getCounter('otel.env.invalid', ddEnvVar, otelEnvVar).inc()
|
|
134
131
|
}
|
|
135
132
|
}
|
|
@@ -200,30 +197,33 @@ function remapify (input, mappings) {
|
|
|
200
197
|
return output
|
|
201
198
|
}
|
|
202
199
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Normalizes propagation style values to a lowercase array.
|
|
202
|
+
* Handles both string (comma-separated) and array inputs.
|
|
203
|
+
*/
|
|
204
|
+
function normalizePropagationStyle (value) {
|
|
205
|
+
if (Array.isArray(value)) {
|
|
206
|
+
return value.map(v => v.toLowerCase())
|
|
207
207
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (
|
|
208
|
+
if (typeof value === 'string') {
|
|
209
|
+
return value.split(',')
|
|
210
|
+
.filter(v => v !== '')
|
|
211
|
+
.map(v => v.trim().toLowerCase())
|
|
212
|
+
}
|
|
213
|
+
if (value !== undefined) {
|
|
214
214
|
log.warn('Unexpected input for config.tracePropagationStyle')
|
|
215
215
|
}
|
|
216
|
+
}
|
|
216
217
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
.map(v => v.trim().toLowerCase())
|
|
218
|
+
/**
|
|
219
|
+
* Warns if both DD_TRACE_PROPAGATION_STYLE and specific inject/extract vars are set.
|
|
220
|
+
*/
|
|
221
|
+
function warnIfPropagationStyleConflict (general, inject, extract) {
|
|
222
|
+
if (general && (inject || extract)) {
|
|
223
|
+
log.warn(
|
|
224
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
225
|
+
'Use either the DD_TRACE_PROPAGATION_STYLE environment variable or separate DD_TRACE_PROPAGATION_STYLE_INJECT and DD_TRACE_PROPAGATION_STYLE_EXTRACT environment variables'
|
|
226
|
+
)
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
@@ -237,16 +237,6 @@ function reformatSpanSamplingRules (rules) {
|
|
|
237
237
|
})
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
const sourcesOrder = [
|
|
241
|
-
{ containerProperty: '_remote', origin: 'remote_config', unprocessedProperty: '_remoteUnprocessed' },
|
|
242
|
-
{ containerProperty: '_options', origin: 'code', unprocessedProperty: '_optsUnprocessed' },
|
|
243
|
-
{ containerProperty: '_fleetStableConfig', origin: 'fleet_stable_config' },
|
|
244
|
-
{ containerProperty: '_env', origin: 'env_var', unprocessedProperty: '_envUnprocessed' },
|
|
245
|
-
{ containerProperty: '_localStableConfig', origin: 'local_stable_config' },
|
|
246
|
-
{ containerProperty: '_calculated', origin: 'calculated' },
|
|
247
|
-
{ containerProperty: '_defaults', origin: 'default' }
|
|
248
|
-
]
|
|
249
|
-
|
|
250
240
|
class Config {
|
|
251
241
|
/**
|
|
252
242
|
* parsed DD_TAGS, usable as a standalone tag set across products
|
|
@@ -254,6 +244,30 @@ class Config {
|
|
|
254
244
|
*/
|
|
255
245
|
#parsedDdTags = {}
|
|
256
246
|
|
|
247
|
+
#envUnprocessed = {}
|
|
248
|
+
#optsUnprocessed = {}
|
|
249
|
+
#remoteUnprocessed = {}
|
|
250
|
+
#env = {}
|
|
251
|
+
#options = {}
|
|
252
|
+
#remote = {}
|
|
253
|
+
#defaults = {}
|
|
254
|
+
#optionsArg = {}
|
|
255
|
+
#localStableConfig = {}
|
|
256
|
+
#fleetStableConfig = {}
|
|
257
|
+
#calculated = {}
|
|
258
|
+
|
|
259
|
+
#getSourcesInOrder () {
|
|
260
|
+
return [
|
|
261
|
+
{ container: this.#remote, origin: 'remote_config', unprocessed: this.#remoteUnprocessed },
|
|
262
|
+
{ container: this.#options, origin: 'code', unprocessed: this.#optsUnprocessed },
|
|
263
|
+
{ container: this.#fleetStableConfig, origin: 'fleet_stable_config' },
|
|
264
|
+
{ container: this.#env, origin: 'env_var', unprocessed: this.#envUnprocessed },
|
|
265
|
+
{ container: this.#localStableConfig, origin: 'local_stable_config' },
|
|
266
|
+
{ container: this.#calculated, origin: 'calculated' },
|
|
267
|
+
{ container: this.#defaults, origin: 'default' }
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
|
|
257
271
|
constructor (options = {}) {
|
|
258
272
|
if (!isInServerlessEnvironment()) {
|
|
259
273
|
// Bail out early if we're in a serverless environment, stable config isn't supported
|
|
@@ -261,6 +275,8 @@ class Config {
|
|
|
261
275
|
this.stableConfig = new StableConfig()
|
|
262
276
|
}
|
|
263
277
|
|
|
278
|
+
const envs = getEnvironmentVariables()
|
|
279
|
+
|
|
264
280
|
options = {
|
|
265
281
|
...options,
|
|
266
282
|
appsec: options.appsec == null ? options.experimental?.appsec : options.appsec,
|
|
@@ -289,25 +305,6 @@ class Config {
|
|
|
289
305
|
|
|
290
306
|
checkIfBothOtelAndDdEnvVarSet()
|
|
291
307
|
|
|
292
|
-
const DD_API_KEY = getEnvironmentVariable('DD_API_KEY')
|
|
293
|
-
const DD_APP_KEY = getEnvironmentVariable('DD_APP_KEY')
|
|
294
|
-
|
|
295
|
-
if (getEnvironmentVariable('DD_TRACE_PROPAGATION_STYLE') && (
|
|
296
|
-
getEnvironmentVariable('DD_TRACE_PROPAGATION_STYLE_INJECT') ||
|
|
297
|
-
getEnvironmentVariable('DD_TRACE_PROPAGATION_STYLE_EXTRACT')
|
|
298
|
-
)) {
|
|
299
|
-
log.warn(
|
|
300
|
-
// eslint-disable-next-line @stylistic/max-len
|
|
301
|
-
'Use either the DD_TRACE_PROPAGATION_STYLE environment variable or separate DD_TRACE_PROPAGATION_STYLE_INJECT and DD_TRACE_PROPAGATION_STYLE_EXTRACT environment variables'
|
|
302
|
-
)
|
|
303
|
-
}
|
|
304
|
-
const PROPAGATION_STYLE_INJECT = propagationStyle(
|
|
305
|
-
'inject',
|
|
306
|
-
options.tracePropagationStyle
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
validateOtelPropagators(PROPAGATION_STYLE_INJECT)
|
|
310
|
-
|
|
311
308
|
if (typeof options.appsec === 'boolean') {
|
|
312
309
|
options.appsec = {
|
|
313
310
|
enabled: options.appsec
|
|
@@ -320,55 +317,15 @@ class Config {
|
|
|
320
317
|
}
|
|
321
318
|
}
|
|
322
319
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
)
|
|
332
|
-
|
|
333
|
-
const DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING = splitJSONPathRules(
|
|
334
|
-
getEnvironmentVariable('DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING') ??
|
|
335
|
-
options.cloudPayloadTagging?.response ??
|
|
336
|
-
''
|
|
337
|
-
)
|
|
338
|
-
|
|
339
|
-
const DD_TRACE_CLOUD_PAYLOAD_TAGGING_MAX_DEPTH = maybeInt(
|
|
340
|
-
getEnvironmentVariable('DD_TRACE_CLOUD_PAYLOAD_TAGGING_MAX_DEPTH') ??
|
|
341
|
-
options.cloudPayloadTagging?.maxDepth
|
|
342
|
-
) ?? 10
|
|
343
|
-
|
|
344
|
-
// TODO: refactor
|
|
345
|
-
this.apiKey = DD_API_KEY
|
|
346
|
-
this.appKey = DD_APP_KEY
|
|
347
|
-
|
|
348
|
-
// sent in telemetry event app-started
|
|
349
|
-
this.installSignature = {
|
|
350
|
-
id: DD_INSTRUMENTATION_INSTALL_ID,
|
|
351
|
-
time: DD_INSTRUMENTATION_INSTALL_TIME,
|
|
352
|
-
type: DD_INSTRUMENTATION_INSTALL_TYPE
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
this.cloudPayloadTagging = {
|
|
356
|
-
requestsEnabled: !!DD_TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING,
|
|
357
|
-
responsesEnabled: !!DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING,
|
|
358
|
-
maxDepth: DD_TRACE_CLOUD_PAYLOAD_TAGGING_MAX_DEPTH,
|
|
359
|
-
rules: appendRules(
|
|
360
|
-
DD_TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING, DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING
|
|
361
|
-
)
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
this._applyDefaults()
|
|
365
|
-
this._applyLocalStableConfig()
|
|
366
|
-
this._applyEnvironment()
|
|
367
|
-
this._applyFleetStableConfig()
|
|
368
|
-
this._applyOptions(options)
|
|
369
|
-
this._applyCalculated()
|
|
370
|
-
this._applyRemote({})
|
|
371
|
-
this._merge()
|
|
320
|
+
this.#defaults = defaults
|
|
321
|
+
this.#applyDefaults()
|
|
322
|
+
this.#applyStableConfig(this.stableConfig?.localEntries ?? {}, this.#localStableConfig)
|
|
323
|
+
this.#applyEnvironment(envs)
|
|
324
|
+
this.#applyStableConfig(this.stableConfig?.fleetEntries ?? {}, this.#fleetStableConfig)
|
|
325
|
+
this.#applyOptions(options)
|
|
326
|
+
this.#applyCalculated()
|
|
327
|
+
this.#applyRemote({})
|
|
328
|
+
this.#merge()
|
|
372
329
|
|
|
373
330
|
tagger.add(this.tags, {
|
|
374
331
|
service: this.service,
|
|
@@ -384,7 +341,7 @@ class Config {
|
|
|
384
341
|
}
|
|
385
342
|
|
|
386
343
|
if (this.gitMetadataEnabled) {
|
|
387
|
-
this
|
|
344
|
+
this.#loadGitMetadata(envs)
|
|
388
345
|
}
|
|
389
346
|
}
|
|
390
347
|
|
|
@@ -395,20 +352,20 @@ class Config {
|
|
|
395
352
|
// Supports only a subset of options for now.
|
|
396
353
|
configure (options, remote) {
|
|
397
354
|
if (remote) {
|
|
398
|
-
this
|
|
355
|
+
this.#applyRemote(options)
|
|
399
356
|
} else {
|
|
400
|
-
this
|
|
357
|
+
this.#applyOptions(options)
|
|
401
358
|
}
|
|
402
359
|
|
|
403
360
|
// TODO: test
|
|
404
|
-
this
|
|
405
|
-
this
|
|
361
|
+
this.#applyCalculated()
|
|
362
|
+
this.#merge()
|
|
406
363
|
}
|
|
407
364
|
|
|
408
|
-
|
|
365
|
+
#getDefaultPropagationStyle (options) {
|
|
409
366
|
// TODO: Remove the experimental env vars as a major?
|
|
410
367
|
const DD_TRACE_B3_ENABLED = options.experimental?.b3 ??
|
|
411
|
-
|
|
368
|
+
getEnv('DD_TRACE_EXPERIMENTAL_B3_ENABLED')
|
|
412
369
|
const defaultPropagationStyle = ['datadog', 'tracecontext']
|
|
413
370
|
if (isTrue(DD_TRACE_B3_ENABLED)) {
|
|
414
371
|
defaultPropagationStyle.push('b3', 'b3 single header')
|
|
@@ -420,51 +377,33 @@ class Config {
|
|
|
420
377
|
return isInServerlessEnvironment()
|
|
421
378
|
}
|
|
422
379
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
setHiddenProperty(this, '_defaults', defaults)
|
|
380
|
+
#applyStableConfig (config, obj) {
|
|
381
|
+
this.#applyConfigValues(config, obj, {})
|
|
426
382
|
}
|
|
427
383
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
384
|
+
// Set environment-dependent defaults that can be overridden by users
|
|
385
|
+
#applyDefaults () {
|
|
386
|
+
const defaults = this.#defaults
|
|
432
387
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
388
|
+
if (isInServerlessEnvironment()) {
|
|
389
|
+
this.#setBoolean(defaults, 'crashtracking.enabled', false)
|
|
390
|
+
this.#setString(defaults, 'profiling.enabled', 'false')
|
|
391
|
+
this.#setBoolean(defaults, 'telemetry.enabled', false)
|
|
392
|
+
this.#setBoolean(defaults, 'remoteConfig.enabled', false)
|
|
393
|
+
} else {
|
|
394
|
+
this.#setBoolean(defaults, 'crashtracking.enabled', true)
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (getEnv('JEST_WORKER_ID')) {
|
|
398
|
+
this.#setBoolean(defaults, 'telemetry.enabled', false)
|
|
399
|
+
}
|
|
436
400
|
}
|
|
437
401
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
DD_APPSEC_ENABLED,
|
|
441
|
-
DD_APPSEC_SCA_ENABLED,
|
|
442
|
-
DD_DATA_STREAMS_ENABLED,
|
|
443
|
-
DD_DYNAMIC_INSTRUMENTATION_ENABLED,
|
|
444
|
-
DD_ENV,
|
|
445
|
-
DD_IAST_ENABLED,
|
|
446
|
-
DD_LOGS_INJECTION,
|
|
447
|
-
DD_PROFILING_ENABLED,
|
|
448
|
-
DD_RUNTIME_METRICS_ENABLED,
|
|
449
|
-
DD_SERVICE,
|
|
450
|
-
DD_VERSION
|
|
451
|
-
} = config
|
|
452
|
-
|
|
453
|
-
this._setBoolean(obj, 'appsec.enabled', DD_APPSEC_ENABLED)
|
|
454
|
-
this._setBoolean(obj, 'appsec.sca.enabled', DD_APPSEC_SCA_ENABLED)
|
|
455
|
-
this._setBoolean(obj, 'dsmEnabled', DD_DATA_STREAMS_ENABLED)
|
|
456
|
-
this._setBoolean(obj, 'dynamicInstrumentation.enabled', DD_DYNAMIC_INSTRUMENTATION_ENABLED)
|
|
457
|
-
this._setString(obj, 'env', DD_ENV)
|
|
458
|
-
this._setBoolean(obj, 'iast.enabled', DD_IAST_ENABLED)
|
|
459
|
-
this._setBoolean(obj, 'logInjection', DD_LOGS_INJECTION)
|
|
460
|
-
const profilingEnabled = normalizeProfilingEnabledValue(DD_PROFILING_ENABLED)
|
|
461
|
-
this._setString(obj, 'profiling.enabled', profilingEnabled)
|
|
462
|
-
this._setBoolean(obj, 'runtimeMetrics.enabled', DD_RUNTIME_METRICS_ENABLED)
|
|
463
|
-
this._setString(obj, 'service', DD_SERVICE)
|
|
464
|
-
this._setString(obj, 'version', DD_VERSION)
|
|
402
|
+
#applyEnvironment () {
|
|
403
|
+
this.#applyConfigValues(getEnvironmentVariables(), this.#env, this.#envUnprocessed)
|
|
465
404
|
}
|
|
466
405
|
|
|
467
|
-
|
|
406
|
+
#applyConfigValues (source, target, unprocessedTarget) {
|
|
468
407
|
const {
|
|
469
408
|
AWS_LAMBDA_FUNCTION_NAME,
|
|
470
409
|
DD_AGENT_HOST,
|
|
@@ -473,11 +412,13 @@ class Config {
|
|
|
473
412
|
DD_AI_GUARD_MAX_CONTENT_SIZE,
|
|
474
413
|
DD_AI_GUARD_MAX_MESSAGES_LENGTH,
|
|
475
414
|
DD_AI_GUARD_TIMEOUT,
|
|
415
|
+
DD_API_KEY,
|
|
476
416
|
DD_API_SECURITY_ENABLED,
|
|
477
417
|
DD_API_SECURITY_SAMPLE_DELAY,
|
|
478
418
|
DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED,
|
|
479
419
|
DD_API_SECURITY_ENDPOINT_COLLECTION_MESSAGE_LIMIT,
|
|
480
420
|
DD_APM_TRACING_ENABLED,
|
|
421
|
+
DD_APP_KEY,
|
|
481
422
|
DD_APPSEC_AUTO_USER_INSTRUMENTATION_MODE,
|
|
482
423
|
DD_APPSEC_COLLECT_ALL_HEADERS,
|
|
483
424
|
DD_APPSEC_ENABLED,
|
|
@@ -514,7 +455,6 @@ class Config {
|
|
|
514
455
|
DD_PROFILING_ENABLED,
|
|
515
456
|
DD_GRPC_CLIENT_ERROR_STATUSES,
|
|
516
457
|
DD_GRPC_SERVER_ERROR_STATUSES,
|
|
517
|
-
JEST_WORKER_ID,
|
|
518
458
|
DD_HEAP_SNAPSHOT_COUNT,
|
|
519
459
|
DD_HEAP_SNAPSHOT_DESTINATION,
|
|
520
460
|
DD_HEAP_SNAPSHOT_INTERVAL,
|
|
@@ -546,6 +486,9 @@ class Config {
|
|
|
546
486
|
DD_PROFILING_EXPORTERS,
|
|
547
487
|
DD_PROFILING_SOURCE_MAP,
|
|
548
488
|
DD_INTERNAL_PROFILING_LONG_LIVED_THRESHOLD,
|
|
489
|
+
DD_INSTRUMENTATION_INSTALL_ID,
|
|
490
|
+
DD_INSTRUMENTATION_INSTALL_TIME,
|
|
491
|
+
DD_INSTRUMENTATION_INSTALL_TYPE,
|
|
549
492
|
DD_REMOTE_CONFIGURATION_ENABLED,
|
|
550
493
|
DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS,
|
|
551
494
|
DD_RUNTIME_METRICS_ENABLED,
|
|
@@ -572,6 +515,9 @@ class Config {
|
|
|
572
515
|
DD_TRACE_BAGGAGE_TAG_KEYS,
|
|
573
516
|
DD_TRACE_CLIENT_IP_ENABLED,
|
|
574
517
|
DD_TRACE_CLIENT_IP_HEADER,
|
|
518
|
+
DD_TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING,
|
|
519
|
+
DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING,
|
|
520
|
+
DD_TRACE_CLOUD_PAYLOAD_TAGGING_MAX_DEPTH,
|
|
575
521
|
DD_TRACE_DYNAMODB_TABLE_PRIMARY_KEYS,
|
|
576
522
|
DD_TRACE_ENABLED,
|
|
577
523
|
DD_TRACE_EXPERIMENTAL_EXPORTER,
|
|
@@ -586,6 +532,7 @@ class Config {
|
|
|
586
532
|
DD_TRACE_MIDDLEWARE_TRACING_ENABLED,
|
|
587
533
|
DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP,
|
|
588
534
|
DD_TRACE_PARTIAL_FLUSH_MIN_SPANS,
|
|
535
|
+
DD_TRACE_FLUSH_INTERVAL,
|
|
589
536
|
DD_TRACE_PEER_SERVICE_MAPPING,
|
|
590
537
|
DD_TRACE_PROPAGATION_EXTRACT_FIRST,
|
|
591
538
|
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT,
|
|
@@ -629,474 +576,564 @@ class Config {
|
|
|
629
576
|
OTEL_EXPORTER_OTLP_TIMEOUT,
|
|
630
577
|
OTEL_BSP_SCHEDULE_DELAY,
|
|
631
578
|
OTEL_BSP_MAX_EXPORT_BATCH_SIZE
|
|
632
|
-
} =
|
|
579
|
+
} = source
|
|
633
580
|
|
|
634
581
|
const tags = {}
|
|
635
|
-
const env = setHiddenProperty(this, '_env', {})
|
|
636
|
-
setHiddenProperty(this, '_envUnprocessed', {})
|
|
637
582
|
|
|
638
|
-
|
|
583
|
+
const parsedDdTags = parseSpaceSeparatedTags(DD_TAGS)
|
|
584
|
+
tagger.add(this.#parsedDdTags, parsedDdTags)
|
|
639
585
|
|
|
640
586
|
tagger.add(tags, parseSpaceSeparatedTags(handleOtel(OTEL_RESOURCE_ATTRIBUTES)))
|
|
641
|
-
tagger.add(tags,
|
|
587
|
+
tagger.add(tags, parsedDdTags)
|
|
642
588
|
tagger.add(tags, DD_TRACE_TAGS)
|
|
643
589
|
tagger.add(tags, DD_TRACE_GLOBAL_TAGS)
|
|
644
590
|
|
|
645
|
-
this
|
|
591
|
+
this.#setString(target, 'apiKey', DD_API_KEY)
|
|
592
|
+
this.#setBoolean(target, 'otelLogsEnabled', DD_LOGS_OTEL_ENABLED)
|
|
646
593
|
// Set OpenTelemetry logs configuration with specific _LOGS_ vars taking precedence over generic _EXPORTERS_ vars
|
|
647
594
|
if (OTEL_EXPORTER_OTLP_ENDPOINT) {
|
|
648
595
|
// Only set if there's a custom URL, otherwise let calc phase handle the default
|
|
649
|
-
this
|
|
596
|
+
this.#setString(target, 'otelUrl', OTEL_EXPORTER_OTLP_ENDPOINT)
|
|
650
597
|
}
|
|
651
598
|
if (OTEL_EXPORTER_OTLP_ENDPOINT || OTEL_EXPORTER_OTLP_LOGS_ENDPOINT) {
|
|
652
|
-
this
|
|
599
|
+
this.#setString(target, 'otelLogsUrl', OTEL_EXPORTER_OTLP_LOGS_ENDPOINT || target.otelUrl)
|
|
653
600
|
}
|
|
654
|
-
this
|
|
655
|
-
this
|
|
656
|
-
this
|
|
657
|
-
this
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
this
|
|
663
|
-
|
|
601
|
+
this.#setString(target, 'otelHeaders', OTEL_EXPORTER_OTLP_HEADERS)
|
|
602
|
+
this.#setString(target, 'otelLogsHeaders', OTEL_EXPORTER_OTLP_LOGS_HEADERS || target.otelHeaders)
|
|
603
|
+
this.#setString(target, 'otelProtocol', OTEL_EXPORTER_OTLP_PROTOCOL)
|
|
604
|
+
this.#setString(target, 'otelLogsProtocol', OTEL_EXPORTER_OTLP_LOGS_PROTOCOL || target.otelProtocol)
|
|
605
|
+
target.otelTimeout = maybeInt(OTEL_EXPORTER_OTLP_TIMEOUT)
|
|
606
|
+
target.otelLogsTimeout = maybeInt(OTEL_EXPORTER_OTLP_LOGS_TIMEOUT) || target.otelTimeout
|
|
607
|
+
target.otelLogsBatchTimeout = maybeInt(OTEL_BSP_SCHEDULE_DELAY)
|
|
608
|
+
target.otelLogsMaxExportBatchSize = maybeInt(OTEL_BSP_MAX_EXPORT_BATCH_SIZE)
|
|
609
|
+
this.#setBoolean(
|
|
610
|
+
target,
|
|
664
611
|
'apmTracingEnabled',
|
|
665
612
|
DD_APM_TRACING_ENABLED ??
|
|
666
613
|
(DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED && isFalse(DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED))
|
|
667
614
|
)
|
|
668
|
-
this
|
|
669
|
-
|
|
670
|
-
|
|
615
|
+
this.#setString(target, 'appKey', DD_APP_KEY)
|
|
616
|
+
this.#setBoolean(target, 'appsec.apiSecurity.enabled', DD_API_SECURITY_ENABLED && isTrue(DD_API_SECURITY_ENABLED))
|
|
617
|
+
target['appsec.apiSecurity.sampleDelay'] = maybeFloat(DD_API_SECURITY_SAMPLE_DELAY)
|
|
618
|
+
this.#setBoolean(target, 'appsec.apiSecurity.endpointCollectionEnabled',
|
|
671
619
|
DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED)
|
|
672
|
-
|
|
620
|
+
target['appsec.apiSecurity.endpointCollectionMessageLimit'] =
|
|
673
621
|
maybeInt(DD_API_SECURITY_ENDPOINT_COLLECTION_MESSAGE_LIMIT)
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
this
|
|
680
|
-
this
|
|
622
|
+
target['appsec.blockedTemplateGraphql'] = maybeFile(DD_APPSEC_GRAPHQL_BLOCKED_TEMPLATE_JSON)
|
|
623
|
+
target['appsec.blockedTemplateHtml'] = maybeFile(DD_APPSEC_HTTP_BLOCKED_TEMPLATE_HTML)
|
|
624
|
+
unprocessedTarget['appsec.blockedTemplateHtml'] = DD_APPSEC_HTTP_BLOCKED_TEMPLATE_HTML
|
|
625
|
+
target['appsec.blockedTemplateJson'] = maybeFile(DD_APPSEC_HTTP_BLOCKED_TEMPLATE_JSON)
|
|
626
|
+
unprocessedTarget['appsec.blockedTemplateJson'] = DD_APPSEC_HTTP_BLOCKED_TEMPLATE_JSON
|
|
627
|
+
this.#setBoolean(target, 'appsec.enabled', DD_APPSEC_ENABLED)
|
|
628
|
+
this.#setString(target, 'appsec.eventTracking.mode', DD_APPSEC_AUTO_USER_INSTRUMENTATION_MODE)
|
|
681
629
|
// TODO appsec.extendedHeadersCollection are deprecated, to delete in a major
|
|
682
|
-
this
|
|
683
|
-
this
|
|
684
|
-
|
|
630
|
+
this.#setBoolean(target, 'appsec.extendedHeadersCollection.enabled', DD_APPSEC_COLLECT_ALL_HEADERS)
|
|
631
|
+
this.#setBoolean(
|
|
632
|
+
target,
|
|
685
633
|
'appsec.extendedHeadersCollection.redaction',
|
|
686
634
|
DD_APPSEC_HEADER_COLLECTION_REDACTION_ENABLED
|
|
687
635
|
)
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
this
|
|
691
|
-
this
|
|
692
|
-
this
|
|
636
|
+
target['appsec.extendedHeadersCollection.maxHeaders'] = maybeInt(DD_APPSEC_MAX_COLLECTED_HEADERS)
|
|
637
|
+
unprocessedTarget['appsec.extendedHeadersCollection.maxHeaders'] = DD_APPSEC_MAX_COLLECTED_HEADERS
|
|
638
|
+
this.#setString(target, 'appsec.obfuscatorKeyRegex', DD_APPSEC_OBFUSCATION_PARAMETER_KEY_REGEXP)
|
|
639
|
+
this.#setString(target, 'appsec.obfuscatorValueRegex', DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP)
|
|
640
|
+
this.#setBoolean(target, 'appsec.rasp.enabled', DD_APPSEC_RASP_ENABLED)
|
|
693
641
|
// TODO Deprecated, to delete in a major
|
|
694
|
-
this
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
this
|
|
642
|
+
this.#setBoolean(target, 'appsec.rasp.bodyCollection', DD_APPSEC_RASP_COLLECT_REQUEST_BODY)
|
|
643
|
+
target['appsec.rateLimit'] = maybeInt(DD_APPSEC_TRACE_RATE_LIMIT)
|
|
644
|
+
unprocessedTarget['appsec.rateLimit'] = DD_APPSEC_TRACE_RATE_LIMIT
|
|
645
|
+
this.#setString(target, 'appsec.rules', DD_APPSEC_RULES)
|
|
698
646
|
// DD_APPSEC_SCA_ENABLED is never used locally, but only sent to the backend
|
|
699
|
-
this
|
|
700
|
-
this
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
this
|
|
711
|
-
this
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
647
|
+
this.#setBoolean(target, 'appsec.sca.enabled', DD_APPSEC_SCA_ENABLED)
|
|
648
|
+
this.#setBoolean(target, 'appsec.stackTrace.enabled', DD_APPSEC_STACK_TRACE_ENABLED)
|
|
649
|
+
target['appsec.stackTrace.maxDepth'] = maybeInt(DD_APPSEC_MAX_STACK_TRACE_DEPTH)
|
|
650
|
+
unprocessedTarget['appsec.stackTrace.maxDepth'] = DD_APPSEC_MAX_STACK_TRACE_DEPTH
|
|
651
|
+
target['appsec.stackTrace.maxStackTraces'] = maybeInt(DD_APPSEC_MAX_STACK_TRACES)
|
|
652
|
+
unprocessedTarget['appsec.stackTrace.maxStackTraces'] = DD_APPSEC_MAX_STACK_TRACES
|
|
653
|
+
target['appsec.wafTimeout'] = maybeInt(DD_APPSEC_WAF_TIMEOUT)
|
|
654
|
+
unprocessedTarget['appsec.wafTimeout'] = DD_APPSEC_WAF_TIMEOUT
|
|
655
|
+
target.baggageMaxBytes = DD_TRACE_BAGGAGE_MAX_BYTES
|
|
656
|
+
target.baggageMaxItems = DD_TRACE_BAGGAGE_MAX_ITEMS
|
|
657
|
+
target.baggageTagKeys = DD_TRACE_BAGGAGE_TAG_KEYS
|
|
658
|
+
this.#setBoolean(target, 'clientIpEnabled', DD_TRACE_CLIENT_IP_ENABLED)
|
|
659
|
+
this.#setString(target, 'clientIpHeader', DD_TRACE_CLIENT_IP_HEADER?.toLowerCase())
|
|
660
|
+
if (DD_TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING || DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING) {
|
|
661
|
+
if (DD_TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING) {
|
|
662
|
+
this.#setBoolean(target, 'cloudPayloadTagging.requestsEnabled', true)
|
|
663
|
+
}
|
|
664
|
+
if (DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING) {
|
|
665
|
+
this.#setBoolean(target, 'cloudPayloadTagging.responsesEnabled', true)
|
|
666
|
+
}
|
|
667
|
+
target['cloudPayloadTagging.rules'] = appendRules(
|
|
668
|
+
splitJSONPathRules(DD_TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING),
|
|
669
|
+
splitJSONPathRules(DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING)
|
|
670
|
+
)
|
|
671
|
+
}
|
|
672
|
+
if (DD_TRACE_CLOUD_PAYLOAD_TAGGING_MAX_DEPTH) {
|
|
673
|
+
target['cloudPayloadTagging.maxDepth'] = maybeInt(DD_TRACE_CLOUD_PAYLOAD_TAGGING_MAX_DEPTH)
|
|
674
|
+
}
|
|
675
|
+
this.#setBoolean(target, 'crashtracking.enabled', DD_CRASHTRACKING_ENABLED)
|
|
676
|
+
this.#setBoolean(target, 'codeOriginForSpans.enabled', DD_CODE_ORIGIN_FOR_SPANS_ENABLED)
|
|
677
|
+
this.#setBoolean(
|
|
678
|
+
target,
|
|
716
679
|
'codeOriginForSpans.experimental.exit_spans.enabled',
|
|
717
680
|
DD_CODE_ORIGIN_FOR_SPANS_EXPERIMENTAL_EXIT_SPANS_ENABLED
|
|
718
681
|
)
|
|
719
|
-
this
|
|
720
|
-
this
|
|
721
|
-
this
|
|
722
|
-
this
|
|
723
|
-
this
|
|
724
|
-
this
|
|
725
|
-
this
|
|
726
|
-
|
|
727
|
-
|
|
682
|
+
this.#setString(target, 'dbmPropagationMode', DD_DBM_PROPAGATION_MODE)
|
|
683
|
+
this.#setString(target, 'dogstatsd.hostname', DD_DOGSTATSD_HOST)
|
|
684
|
+
this.#setString(target, 'dogstatsd.port', DD_DOGSTATSD_PORT)
|
|
685
|
+
this.#setBoolean(target, 'dsmEnabled', DD_DATA_STREAMS_ENABLED)
|
|
686
|
+
this.#setBoolean(target, 'dynamicInstrumentation.enabled', DD_DYNAMIC_INSTRUMENTATION_ENABLED)
|
|
687
|
+
this.#setString(target, 'dynamicInstrumentation.probeFile', DD_DYNAMIC_INSTRUMENTATION_PROBE_FILE)
|
|
688
|
+
this.#setArray(target, 'dynamicInstrumentation.redactedIdentifiers',
|
|
689
|
+
DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS)
|
|
690
|
+
this.#setArray(
|
|
691
|
+
target,
|
|
728
692
|
'dynamicInstrumentation.redactionExcludedIdentifiers',
|
|
729
693
|
DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS
|
|
730
694
|
)
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
this
|
|
735
|
-
this
|
|
736
|
-
this
|
|
737
|
-
this
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
this
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
this
|
|
755
|
-
|
|
756
|
-
this
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
this
|
|
760
|
-
|
|
761
|
-
this
|
|
762
|
-
|
|
763
|
-
this
|
|
764
|
-
this
|
|
765
|
-
|
|
766
|
-
|
|
695
|
+
target['dynamicInstrumentation.uploadIntervalSeconds'] =
|
|
696
|
+
maybeFloat(DD_DYNAMIC_INSTRUMENTATION_UPLOAD_INTERVAL_SECONDS)
|
|
697
|
+
unprocessedTarget['dynamicInstrumentation.uploadInterval'] = DD_DYNAMIC_INSTRUMENTATION_UPLOAD_INTERVAL_SECONDS
|
|
698
|
+
this.#setString(target, 'env', DD_ENV || tags.env)
|
|
699
|
+
this.#setBoolean(target, 'experimental.flaggingProvider.enabled', DD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED)
|
|
700
|
+
this.#setBoolean(target, 'traceEnabled', DD_TRACE_ENABLED)
|
|
701
|
+
this.#setBoolean(target, 'experimental.aiguard.enabled', DD_AI_GUARD_ENABLED)
|
|
702
|
+
this.#setString(target, 'experimental.aiguard.endpoint', DD_AI_GUARD_ENDPOINT)
|
|
703
|
+
target['experimental.aiguard.maxContentSize'] = maybeInt(DD_AI_GUARD_MAX_CONTENT_SIZE)
|
|
704
|
+
unprocessedTarget['experimental.aiguard.maxContentSize'] = DD_AI_GUARD_MAX_CONTENT_SIZE
|
|
705
|
+
target['experimental.aiguard.maxMessagesLength'] = maybeInt(DD_AI_GUARD_MAX_MESSAGES_LENGTH)
|
|
706
|
+
unprocessedTarget['experimental.aiguard.maxMessagesLength'] = DD_AI_GUARD_MAX_MESSAGES_LENGTH
|
|
707
|
+
target['experimental.aiguard.timeout'] = maybeInt(DD_AI_GUARD_TIMEOUT)
|
|
708
|
+
unprocessedTarget['experimental.aiguard.timeout'] = DD_AI_GUARD_TIMEOUT
|
|
709
|
+
this.#setBoolean(target, 'experimental.enableGetRumData', DD_TRACE_EXPERIMENTAL_GET_RUM_DATA_ENABLED)
|
|
710
|
+
this.#setString(target, 'experimental.exporter', DD_TRACE_EXPERIMENTAL_EXPORTER)
|
|
711
|
+
if (AWS_LAMBDA_FUNCTION_NAME) {
|
|
712
|
+
target.flushInterval = 0
|
|
713
|
+
} else if (DD_TRACE_FLUSH_INTERVAL) {
|
|
714
|
+
target.flushInterval = maybeInt(DD_TRACE_FLUSH_INTERVAL)
|
|
715
|
+
}
|
|
716
|
+
target.flushMinSpans = maybeInt(DD_TRACE_PARTIAL_FLUSH_MIN_SPANS)
|
|
717
|
+
unprocessedTarget.flushMinSpans = DD_TRACE_PARTIAL_FLUSH_MIN_SPANS
|
|
718
|
+
this.#setBoolean(target, 'gitMetadataEnabled', DD_TRACE_GIT_METADATA_ENABLED)
|
|
719
|
+
this.#setIntegerRangeSet(target, 'grpc.client.error.statuses', DD_GRPC_CLIENT_ERROR_STATUSES)
|
|
720
|
+
this.#setIntegerRangeSet(target, 'grpc.server.error.statuses', DD_GRPC_SERVER_ERROR_STATUSES)
|
|
721
|
+
this.#setArray(target, 'headerTags', DD_TRACE_HEADER_TAGS)
|
|
722
|
+
target['heapSnapshot.count'] = maybeInt(DD_HEAP_SNAPSHOT_COUNT)
|
|
723
|
+
this.#setString(target, 'heapSnapshot.destination', DD_HEAP_SNAPSHOT_DESTINATION)
|
|
724
|
+
target['heapSnapshot.interval'] = maybeInt(DD_HEAP_SNAPSHOT_INTERVAL)
|
|
725
|
+
this.#setString(target, 'hostname', DD_AGENT_HOST)
|
|
726
|
+
target['iast.dbRowsToTaint'] = maybeInt(DD_IAST_DB_ROWS_TO_TAINT)
|
|
727
|
+
this.#setBoolean(target, 'iast.deduplicationEnabled', DD_IAST_DEDUPLICATION_ENABLED)
|
|
728
|
+
this.#setBoolean(target, 'iast.enabled', DD_IAST_ENABLED)
|
|
729
|
+
target['iast.maxConcurrentRequests'] = maybeInt(DD_IAST_MAX_CONCURRENT_REQUESTS)
|
|
730
|
+
unprocessedTarget['iast.maxConcurrentRequests'] = DD_IAST_MAX_CONCURRENT_REQUESTS
|
|
731
|
+
target['iast.maxContextOperations'] = maybeInt(DD_IAST_MAX_CONTEXT_OPERATIONS)
|
|
732
|
+
unprocessedTarget['iast.maxContextOperations'] = DD_IAST_MAX_CONTEXT_OPERATIONS
|
|
733
|
+
this.#setBoolean(target, 'iast.redactionEnabled', DD_IAST_REDACTION_ENABLED && !isFalse(DD_IAST_REDACTION_ENABLED))
|
|
734
|
+
this.#setString(target, 'iast.redactionNamePattern', DD_IAST_REDACTION_NAME_PATTERN)
|
|
735
|
+
this.#setString(target, 'iast.redactionValuePattern', DD_IAST_REDACTION_VALUE_PATTERN)
|
|
767
736
|
const iastRequestSampling = maybeInt(DD_IAST_REQUEST_SAMPLING)
|
|
768
|
-
if (iastRequestSampling > -1 && iastRequestSampling < 101) {
|
|
769
|
-
|
|
737
|
+
if (iastRequestSampling !== undefined && iastRequestSampling > -1 && iastRequestSampling < 101) {
|
|
738
|
+
target['iast.requestSampling'] = iastRequestSampling
|
|
770
739
|
}
|
|
771
|
-
|
|
772
|
-
this
|
|
773
|
-
this
|
|
774
|
-
this
|
|
775
|
-
this
|
|
776
|
-
this
|
|
777
|
-
this
|
|
778
|
-
this
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
this
|
|
783
|
-
this
|
|
784
|
-
this
|
|
785
|
-
|
|
786
|
-
|
|
740
|
+
unprocessedTarget['iast.requestSampling'] = DD_IAST_REQUEST_SAMPLING
|
|
741
|
+
this.#setString(target, 'iast.securityControlsConfiguration', DD_IAST_SECURITY_CONTROLS_CONFIGURATION)
|
|
742
|
+
this.#setString(target, 'iast.telemetryVerbosity', DD_IAST_TELEMETRY_VERBOSITY)
|
|
743
|
+
this.#setBoolean(target, 'iast.stackTrace.enabled', DD_IAST_STACK_TRACE_ENABLED)
|
|
744
|
+
this.#setString(target, 'installSignature.id', DD_INSTRUMENTATION_INSTALL_ID)
|
|
745
|
+
this.#setString(target, 'installSignature.time', DD_INSTRUMENTATION_INSTALL_TIME)
|
|
746
|
+
this.#setString(target, 'installSignature.type', DD_INSTRUMENTATION_INSTALL_TYPE)
|
|
747
|
+
this.#setArray(target, 'injectionEnabled', DD_INJECTION_ENABLED)
|
|
748
|
+
if (DD_INJECTION_ENABLED !== undefined) {
|
|
749
|
+
this.#setString(target, 'instrumentationSource', DD_INJECTION_ENABLED ? 'ssi' : 'manual')
|
|
750
|
+
}
|
|
751
|
+
this.#setBoolean(target, 'injectForce', DD_INJECT_FORCE)
|
|
752
|
+
this.#setBoolean(target, 'isAzureFunction', getIsAzureFunction())
|
|
753
|
+
this.#setBoolean(target, 'isGCPFunction', getIsGCPFunction())
|
|
754
|
+
target['langchain.spanCharLimit'] = maybeInt(DD_LANGCHAIN_SPAN_CHAR_LIMIT)
|
|
755
|
+
target['langchain.spanPromptCompletionSampleRate'] = maybeFloat(DD_LANGCHAIN_SPAN_PROMPT_COMPLETION_SAMPLE_RATE)
|
|
756
|
+
this.#setBoolean(target, 'legacyBaggageEnabled', DD_TRACE_LEGACY_BAGGAGE_ENABLED)
|
|
757
|
+
this.#setBoolean(target, 'llmobs.agentlessEnabled', DD_LLMOBS_AGENTLESS_ENABLED)
|
|
758
|
+
this.#setBoolean(target, 'llmobs.enabled', DD_LLMOBS_ENABLED)
|
|
759
|
+
this.#setString(target, 'llmobs.mlApp', DD_LLMOBS_ML_APP)
|
|
760
|
+
this.#setBoolean(target, 'logInjection', DD_LOGS_INJECTION)
|
|
787
761
|
// Requires an accompanying DD_APM_OBFUSCATION_MEMCACHED_KEEP_COMMAND=true in the agent
|
|
788
|
-
this
|
|
789
|
-
this
|
|
790
|
-
this
|
|
791
|
-
|
|
792
|
-
|
|
762
|
+
this.#setBoolean(target, 'memcachedCommandEnabled', DD_TRACE_MEMCACHED_COMMAND_ENABLED)
|
|
763
|
+
this.#setBoolean(target, 'middlewareTracingEnabled', DD_TRACE_MIDDLEWARE_TRACING_ENABLED)
|
|
764
|
+
this.#setBoolean(target, 'openAiLogsEnabled', DD_OPENAI_LOGS_ENABLED)
|
|
765
|
+
target['openai.spanCharLimit'] = maybeInt(DD_OPENAI_SPAN_CHAR_LIMIT)
|
|
766
|
+
unprocessedTarget.openaiSpanCharLimit = DD_OPENAI_SPAN_CHAR_LIMIT
|
|
793
767
|
if (DD_TRACE_PEER_SERVICE_MAPPING) {
|
|
794
|
-
|
|
768
|
+
target.peerServiceMapping = Object.fromEntries(
|
|
795
769
|
DD_TRACE_PEER_SERVICE_MAPPING.split(',').map(x => x.trim().split(':'))
|
|
796
770
|
)
|
|
797
|
-
|
|
771
|
+
unprocessedTarget.peerServiceMapping = DD_TRACE_PEER_SERVICE_MAPPING
|
|
798
772
|
}
|
|
799
|
-
this
|
|
800
|
-
const profilingEnabled = normalizeProfilingEnabledValue(
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
)
|
|
804
|
-
this._setString(env, 'profiling.enabled', profilingEnabled)
|
|
805
|
-
this._setString(env, 'profiling.exporters', DD_PROFILING_EXPORTERS)
|
|
806
|
-
this._setBoolean(env, 'profiling.sourceMap', DD_PROFILING_SOURCE_MAP && !isFalse(DD_PROFILING_SOURCE_MAP))
|
|
773
|
+
this.#setString(target, 'port', DD_TRACE_AGENT_PORT)
|
|
774
|
+
const profilingEnabled = normalizeProfilingEnabledValue(DD_PROFILING_ENABLED)
|
|
775
|
+
this.#setString(target, 'profiling.enabled', profilingEnabled)
|
|
776
|
+
this.#setString(target, 'profiling.exporters', DD_PROFILING_EXPORTERS)
|
|
777
|
+
this.#setBoolean(target, 'profiling.sourceMap', DD_PROFILING_SOURCE_MAP && !isFalse(DD_PROFILING_SOURCE_MAP))
|
|
807
778
|
if (DD_INTERNAL_PROFILING_LONG_LIVED_THRESHOLD) {
|
|
808
779
|
// This is only used in testing to not have to wait 30s
|
|
809
|
-
|
|
780
|
+
target['profiling.longLivedThreshold'] = Number(DD_INTERNAL_PROFILING_LONG_LIVED_THRESHOLD)
|
|
810
781
|
}
|
|
811
782
|
|
|
812
|
-
this
|
|
813
|
-
this
|
|
814
|
-
this
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
this
|
|
783
|
+
this.#setString(target, 'protocolVersion', DD_TRACE_AGENT_PROTOCOL_VERSION)
|
|
784
|
+
this.#setString(target, 'queryStringObfuscation', DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP)
|
|
785
|
+
this.#setBoolean(target, 'remoteConfig.enabled', DD_REMOTE_CONFIGURATION_ENABLED)
|
|
786
|
+
target['remoteConfig.pollInterval'] = maybeFloat(DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS)
|
|
787
|
+
unprocessedTarget['remoteConfig.pollInterval'] = DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS
|
|
788
|
+
this.#setBoolean(target, 'reportHostname', DD_TRACE_REPORT_HOSTNAME)
|
|
818
789
|
// only used to explicitly set runtimeMetrics to false
|
|
819
790
|
const otelSetRuntimeMetrics = String(OTEL_METRICS_EXPORTER).toLowerCase() === 'none'
|
|
820
791
|
? false
|
|
821
792
|
: undefined
|
|
822
|
-
this
|
|
793
|
+
this.#setBoolean(target, 'runtimeMetrics.enabled', DD_RUNTIME_METRICS_ENABLED ||
|
|
823
794
|
otelSetRuntimeMetrics)
|
|
824
|
-
this
|
|
825
|
-
this
|
|
826
|
-
this
|
|
827
|
-
this
|
|
795
|
+
this.#setBoolean(target, 'runtimeMetrics.eventLoop', DD_RUNTIME_METRICS_EVENT_LOOP_ENABLED)
|
|
796
|
+
this.#setBoolean(target, 'runtimeMetrics.gc', DD_RUNTIME_METRICS_GC_ENABLED)
|
|
797
|
+
this.#setBoolean(target, 'runtimeMetricsRuntimeId', DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED)
|
|
798
|
+
this.#setArray(target, 'sampler.spanSamplingRules', reformatSpanSamplingRules(
|
|
828
799
|
maybeJsonFile(DD_SPAN_SAMPLING_RULES_FILE) ??
|
|
829
800
|
safeJsonParse(DD_SPAN_SAMPLING_RULES)
|
|
830
801
|
))
|
|
831
|
-
this
|
|
802
|
+
this.#setUnit(target, 'sampleRate', DD_TRACE_SAMPLE_RATE ||
|
|
832
803
|
getFromOtelSamplerMap(OTEL_TRACES_SAMPLER, OTEL_TRACES_SAMPLER_ARG))
|
|
833
|
-
|
|
834
|
-
this
|
|
835
|
-
|
|
836
|
-
this
|
|
837
|
-
this
|
|
804
|
+
target['sampler.rateLimit'] = DD_TRACE_RATE_LIMIT
|
|
805
|
+
this.#setSamplingRule(target, 'sampler.rules', safeJsonParse(DD_TRACE_SAMPLING_RULES))
|
|
806
|
+
unprocessedTarget['sampler.rules'] = DD_TRACE_SAMPLING_RULES
|
|
807
|
+
this.#setString(target, 'scope', DD_TRACE_SCOPE)
|
|
808
|
+
this.#setString(target, 'service', DD_SERVICE || tags.service || OTEL_SERVICE_NAME)
|
|
838
809
|
if (DD_SERVICE_MAPPING) {
|
|
839
|
-
|
|
810
|
+
target.serviceMapping = Object.fromEntries(
|
|
840
811
|
DD_SERVICE_MAPPING.split(',').map(x => x.trim().split(':'))
|
|
841
812
|
)
|
|
842
813
|
}
|
|
843
|
-
this
|
|
814
|
+
this.#setString(target, 'site', DD_SITE)
|
|
844
815
|
if (DD_TRACE_SPAN_ATTRIBUTE_SCHEMA) {
|
|
845
|
-
this
|
|
846
|
-
|
|
816
|
+
this.#setString(target, 'spanAttributeSchema', validateNamingVersion(DD_TRACE_SPAN_ATTRIBUTE_SCHEMA))
|
|
817
|
+
unprocessedTarget.spanAttributeSchema = DD_TRACE_SPAN_ATTRIBUTE_SCHEMA
|
|
847
818
|
}
|
|
848
819
|
// 0: disabled, 1: logging, 2: garbage collection + logging
|
|
849
|
-
|
|
850
|
-
this
|
|
851
|
-
this
|
|
852
|
-
this
|
|
853
|
-
|
|
854
|
-
this
|
|
855
|
-
|
|
856
|
-
this
|
|
857
|
-
this
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
this
|
|
861
|
-
this
|
|
862
|
-
this
|
|
863
|
-
this
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
env.tracePropagationBehaviorExtract =
|
|
868
|
-
VALID_PROPAGATION_BEHAVIOR_EXTRACT.has(stringPropagationBehaviorExtract)
|
|
869
|
-
? stringPropagationBehaviorExtract
|
|
870
|
-
: 'continue'
|
|
871
|
-
this._setBoolean(env, 'tracePropagationStyle.otelPropagators',
|
|
872
|
-
DD_TRACE_PROPAGATION_STYLE ||
|
|
873
|
-
DD_TRACE_PROPAGATION_STYLE_INJECT ||
|
|
820
|
+
target.spanLeakDebug = maybeInt(DD_TRACE_SPAN_LEAK_DEBUG)
|
|
821
|
+
this.#setBoolean(target, 'spanRemoveIntegrationFromService', DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED)
|
|
822
|
+
this.#setBoolean(target, 'startupLogs', DD_TRACE_STARTUP_LOGS)
|
|
823
|
+
this.#setTags(target, 'tags', tags)
|
|
824
|
+
target.tagsHeaderMaxLength = DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH
|
|
825
|
+
this.#setBoolean(target, 'telemetry.enabled', DD_INSTRUMENTATION_TELEMETRY_ENABLED)
|
|
826
|
+
this.#setString(target, 'instrumentation_config_id', DD_INSTRUMENTATION_CONFIG_ID)
|
|
827
|
+
this.#setBoolean(target, 'telemetry.debug', DD_TELEMETRY_DEBUG)
|
|
828
|
+
this.#setBoolean(target, 'telemetry.dependencyCollection', DD_TELEMETRY_DEPENDENCY_COLLECTION_ENABLED)
|
|
829
|
+
target['telemetry.heartbeatInterval'] = maybeInt(Math.floor(DD_TELEMETRY_HEARTBEAT_INTERVAL * 1000))
|
|
830
|
+
unprocessedTarget['telemetry.heartbeatInterval'] = DD_TELEMETRY_HEARTBEAT_INTERVAL * 1000
|
|
831
|
+
this.#setBoolean(target, 'telemetry.logCollection', DD_TELEMETRY_LOG_COLLECTION_ENABLED)
|
|
832
|
+
this.#setBoolean(target, 'telemetry.metrics', DD_TELEMETRY_METRICS_ENABLED)
|
|
833
|
+
this.#setBoolean(target, 'traceId128BitGenerationEnabled', DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED)
|
|
834
|
+
this.#setBoolean(target, 'traceId128BitLoggingEnabled', DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED)
|
|
835
|
+
warnIfPropagationStyleConflict(
|
|
836
|
+
DD_TRACE_PROPAGATION_STYLE,
|
|
837
|
+
DD_TRACE_PROPAGATION_STYLE_INJECT,
|
|
874
838
|
DD_TRACE_PROPAGATION_STYLE_EXTRACT
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
839
|
+
)
|
|
840
|
+
if (DD_TRACE_PROPAGATION_STYLE !== undefined) {
|
|
841
|
+
this.#setArray(target, 'tracePropagationStyle.inject', normalizePropagationStyle(DD_TRACE_PROPAGATION_STYLE))
|
|
842
|
+
this.#setArray(target, 'tracePropagationStyle.extract', normalizePropagationStyle(DD_TRACE_PROPAGATION_STYLE))
|
|
843
|
+
}
|
|
844
|
+
if (DD_TRACE_PROPAGATION_STYLE_INJECT !== undefined) {
|
|
845
|
+
this.#setArray(target, 'tracePropagationStyle.inject',
|
|
846
|
+
normalizePropagationStyle(DD_TRACE_PROPAGATION_STYLE_INJECT))
|
|
847
|
+
}
|
|
848
|
+
if (DD_TRACE_PROPAGATION_STYLE_EXTRACT !== undefined) {
|
|
849
|
+
this.#setArray(target, 'tracePropagationStyle.extract',
|
|
850
|
+
normalizePropagationStyle(DD_TRACE_PROPAGATION_STYLE_EXTRACT))
|
|
851
|
+
}
|
|
852
|
+
this.#setBoolean(target, 'tracePropagationExtractFirst', DD_TRACE_PROPAGATION_EXTRACT_FIRST)
|
|
853
|
+
if (DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT !== undefined) {
|
|
854
|
+
const stringPropagationBehaviorExtract = String(DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT)
|
|
855
|
+
target.tracePropagationBehaviorExtract =
|
|
856
|
+
VALID_PROPAGATION_BEHAVIOR_EXTRACT.has(stringPropagationBehaviorExtract)
|
|
857
|
+
? stringPropagationBehaviorExtract
|
|
858
|
+
: 'continue'
|
|
859
|
+
}
|
|
860
|
+
if (DD_TRACE_PROPAGATION_STYLE !== undefined ||
|
|
861
|
+
DD_TRACE_PROPAGATION_STYLE_INJECT !== undefined ||
|
|
862
|
+
DD_TRACE_PROPAGATION_STYLE_EXTRACT !== undefined ||
|
|
863
|
+
OTEL_PROPAGATORS !== undefined) {
|
|
864
|
+
// At least one var is defined, calculate value using truthy logic
|
|
865
|
+
const useDdStyle = DD_TRACE_PROPAGATION_STYLE ||
|
|
866
|
+
DD_TRACE_PROPAGATION_STYLE_INJECT ||
|
|
867
|
+
DD_TRACE_PROPAGATION_STYLE_EXTRACT
|
|
868
|
+
this.#setBoolean(target, 'tracePropagationStyle.otelPropagators',
|
|
869
|
+
useDdStyle ? false : !!OTEL_PROPAGATORS)
|
|
870
|
+
|
|
871
|
+
// Use OTEL_PROPAGATORS if no DD-specific vars are set
|
|
872
|
+
if (!useDdStyle && OTEL_PROPAGATORS) {
|
|
873
|
+
const otelStyles = normalizePropagationStyle(OTEL_PROPAGATORS)
|
|
874
|
+
// Validate OTEL propagators
|
|
875
|
+
for (const style of otelStyles || []) {
|
|
876
|
+
if (!VALID_PROPAGATION_STYLES.has(style)) {
|
|
877
|
+
log.warn('unexpected value %s for OTEL_PROPAGATORS environment variable', style)
|
|
878
|
+
getCounter('otel.env.invalid', 'DD_TRACE_PROPAGATION_STYLE', 'OTEL_PROPAGATORS').inc()
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
// Set inject/extract from OTEL_PROPAGATORS
|
|
882
|
+
if (otelStyles) {
|
|
883
|
+
this.#setArray(target, 'tracePropagationStyle.inject', otelStyles)
|
|
884
|
+
this.#setArray(target, 'tracePropagationStyle.extract', otelStyles)
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
this.#setBoolean(target, 'traceWebsocketMessagesEnabled', DD_TRACE_WEBSOCKET_MESSAGES_ENABLED)
|
|
889
|
+
this.#setBoolean(target, 'traceWebsocketMessagesInheritSampling', DD_TRACE_WEBSOCKET_MESSAGES_INHERIT_SAMPLING)
|
|
890
|
+
this.#setBoolean(target, 'traceWebsocketMessagesSeparateTraces', DD_TRACE_WEBSOCKET_MESSAGES_SEPARATE_TRACES)
|
|
891
|
+
this.#setBoolean(target, 'tracing', DD_TRACING_ENABLED)
|
|
892
|
+
this.#setString(target, 'version', DD_VERSION || tags.version)
|
|
893
|
+
this.#setBoolean(target, 'inferredProxyServicesEnabled', DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED)
|
|
894
|
+
this.#setBoolean(target, 'trace.aws.addSpanPointers', DD_TRACE_AWS_ADD_SPAN_POINTERS)
|
|
895
|
+
this.#setString(target, 'trace.dynamoDb.tablePrimaryKeys', DD_TRACE_DYNAMODB_TABLE_PRIMARY_KEYS)
|
|
896
|
+
this.#setArray(target, 'graphqlErrorExtensions', DD_TRACE_GRAPHQL_ERROR_EXTENSIONS)
|
|
897
|
+
this.#setBoolean(target, 'trace.nativeSpanEvents', DD_TRACE_NATIVE_SPAN_EVENTS)
|
|
898
|
+
target['vertexai.spanPromptCompletionSampleRate'] = maybeFloat(DD_VERTEXAI_SPAN_PROMPT_COMPLETION_SAMPLE_RATE)
|
|
899
|
+
target['vertexai.spanCharLimit'] = maybeInt(DD_VERTEXAI_SPAN_CHAR_LIMIT)
|
|
889
900
|
}
|
|
890
901
|
|
|
891
|
-
|
|
892
|
-
const opts =
|
|
902
|
+
#applyOptions (options) {
|
|
903
|
+
const opts = this.#options
|
|
893
904
|
const tags = {}
|
|
894
|
-
setHiddenProperty(this, '_optsUnprocessed', {})
|
|
895
905
|
|
|
896
|
-
options =
|
|
906
|
+
options = this.#optionsArg = { ingestion: {}, ...options, ...opts }
|
|
897
907
|
|
|
898
908
|
tagger.add(tags, options.tags)
|
|
899
909
|
|
|
900
|
-
this
|
|
910
|
+
this.#setBoolean(opts, 'apmTracingEnabled', options.apmTracingEnabled ??
|
|
901
911
|
(options.experimental?.appsec?.standalone && !options.experimental.appsec.standalone.enabled)
|
|
902
912
|
)
|
|
903
|
-
this
|
|
904
|
-
this
|
|
913
|
+
this.#setBoolean(opts, 'appsec.apiSecurity.enabled', options.appsec?.apiSecurity?.enabled)
|
|
914
|
+
this.#setBoolean(opts, 'appsec.apiSecurity.endpointCollectionEnabled',
|
|
905
915
|
options.appsec?.apiSecurity?.endpointCollectionEnabled)
|
|
906
916
|
opts['appsec.apiSecurity.endpointCollectionMessageLimit'] =
|
|
907
917
|
maybeInt(options.appsec?.apiSecurity?.endpointCollectionMessageLimit)
|
|
908
918
|
opts['appsec.blockedTemplateGraphql'] = maybeFile(options.appsec?.blockedTemplateGraphql)
|
|
909
919
|
opts['appsec.blockedTemplateHtml'] = maybeFile(options.appsec?.blockedTemplateHtml)
|
|
910
|
-
this
|
|
920
|
+
this.#optsUnprocessed['appsec.blockedTemplateHtml'] = options.appsec?.blockedTemplateHtml
|
|
911
921
|
opts['appsec.blockedTemplateJson'] = maybeFile(options.appsec?.blockedTemplateJson)
|
|
912
|
-
this
|
|
913
|
-
this
|
|
914
|
-
this
|
|
915
|
-
this
|
|
922
|
+
this.#optsUnprocessed['appsec.blockedTemplateJson'] = options.appsec?.blockedTemplateJson
|
|
923
|
+
this.#setBoolean(opts, 'appsec.enabled', options.appsec?.enabled)
|
|
924
|
+
this.#setString(opts, 'appsec.eventTracking.mode', options.appsec?.eventTracking?.mode)
|
|
925
|
+
this.#setBoolean(
|
|
916
926
|
opts,
|
|
917
927
|
'appsec.extendedHeadersCollection.enabled',
|
|
918
928
|
options.appsec?.extendedHeadersCollection?.enabled
|
|
919
929
|
)
|
|
920
|
-
this
|
|
930
|
+
this.#setBoolean(
|
|
921
931
|
opts,
|
|
922
932
|
'appsec.extendedHeadersCollection.redaction',
|
|
923
933
|
options.appsec?.extendedHeadersCollection?.redaction
|
|
924
934
|
)
|
|
925
935
|
opts['appsec.extendedHeadersCollection.maxHeaders'] = options.appsec?.extendedHeadersCollection?.maxHeaders
|
|
926
|
-
this
|
|
927
|
-
this
|
|
928
|
-
this
|
|
929
|
-
this
|
|
936
|
+
this.#setString(opts, 'appsec.obfuscatorKeyRegex', options.appsec?.obfuscatorKeyRegex)
|
|
937
|
+
this.#setString(opts, 'appsec.obfuscatorValueRegex', options.appsec?.obfuscatorValueRegex)
|
|
938
|
+
this.#setBoolean(opts, 'appsec.rasp.enabled', options.appsec?.rasp?.enabled)
|
|
939
|
+
this.#setBoolean(opts, 'appsec.rasp.bodyCollection', options.appsec?.rasp?.bodyCollection)
|
|
930
940
|
opts['appsec.rateLimit'] = maybeInt(options.appsec?.rateLimit)
|
|
931
|
-
this
|
|
932
|
-
this
|
|
933
|
-
this
|
|
941
|
+
this.#optsUnprocessed['appsec.rateLimit'] = options.appsec?.rateLimit
|
|
942
|
+
this.#setString(opts, 'appsec.rules', options.appsec?.rules)
|
|
943
|
+
this.#setBoolean(opts, 'appsec.stackTrace.enabled', options.appsec?.stackTrace?.enabled)
|
|
934
944
|
opts['appsec.stackTrace.maxDepth'] = maybeInt(options.appsec?.stackTrace?.maxDepth)
|
|
935
|
-
this
|
|
945
|
+
this.#optsUnprocessed['appsec.stackTrace.maxDepth'] = options.appsec?.stackTrace?.maxDepth
|
|
936
946
|
opts['appsec.stackTrace.maxStackTraces'] = maybeInt(options.appsec?.stackTrace?.maxStackTraces)
|
|
937
|
-
this
|
|
947
|
+
this.#optsUnprocessed['appsec.stackTrace.maxStackTraces'] = options.appsec?.stackTrace?.maxStackTraces
|
|
938
948
|
opts['appsec.wafTimeout'] = maybeInt(options.appsec?.wafTimeout)
|
|
939
|
-
this
|
|
940
|
-
this
|
|
941
|
-
this
|
|
949
|
+
this.#optsUnprocessed['appsec.wafTimeout'] = options.appsec?.wafTimeout
|
|
950
|
+
this.#setBoolean(opts, 'clientIpEnabled', options.clientIpEnabled)
|
|
951
|
+
this.#setString(opts, 'clientIpHeader', options.clientIpHeader?.toLowerCase())
|
|
952
|
+
if (options.cloudPayloadTagging?.request || options.cloudPayloadTagging?.response) {
|
|
953
|
+
if (options.cloudPayloadTagging.request) {
|
|
954
|
+
this.#setBoolean(opts, 'cloudPayloadTagging.requestsEnabled', true)
|
|
955
|
+
}
|
|
956
|
+
if (options.cloudPayloadTagging.response) {
|
|
957
|
+
this.#setBoolean(opts, 'cloudPayloadTagging.responsesEnabled', true)
|
|
958
|
+
}
|
|
959
|
+
opts['cloudPayloadTagging.rules'] = appendRules(
|
|
960
|
+
splitJSONPathRules(options.cloudPayloadTagging.request),
|
|
961
|
+
splitJSONPathRules(options.cloudPayloadTagging.response)
|
|
962
|
+
)
|
|
963
|
+
}
|
|
964
|
+
if (options.cloudPayloadTagging?.requestsEnabled !== undefined) {
|
|
965
|
+
this.#setBoolean(opts, 'cloudPayloadTagging.requestsEnabled', options.cloudPayloadTagging.requestsEnabled)
|
|
966
|
+
}
|
|
967
|
+
if (options.cloudPayloadTagging?.responsesEnabled !== undefined) {
|
|
968
|
+
this.#setBoolean(opts, 'cloudPayloadTagging.responsesEnabled', options.cloudPayloadTagging.responsesEnabled)
|
|
969
|
+
}
|
|
970
|
+
opts['cloudPayloadTagging.maxDepth'] = maybeInt(options.cloudPayloadTagging?.maxDepth)
|
|
942
971
|
opts.baggageMaxBytes = options.baggageMaxBytes
|
|
943
972
|
opts.baggageMaxItems = options.baggageMaxItems
|
|
944
973
|
opts.baggageTagKeys = options.baggageTagKeys
|
|
945
|
-
this
|
|
946
|
-
this
|
|
974
|
+
this.#setBoolean(opts, 'codeOriginForSpans.enabled', options.codeOriginForSpans?.enabled)
|
|
975
|
+
this.#setBoolean(
|
|
947
976
|
opts,
|
|
948
977
|
'codeOriginForSpans.experimental.exit_spans.enabled',
|
|
949
978
|
options.codeOriginForSpans?.experimental?.exit_spans?.enabled
|
|
950
979
|
)
|
|
951
|
-
this
|
|
980
|
+
this.#setString(opts, 'dbmPropagationMode', options.dbmPropagationMode)
|
|
952
981
|
if (options.dogstatsd) {
|
|
953
|
-
this
|
|
954
|
-
this
|
|
982
|
+
this.#setString(opts, 'dogstatsd.hostname', options.dogstatsd.hostname)
|
|
983
|
+
this.#setString(opts, 'dogstatsd.port', options.dogstatsd.port)
|
|
955
984
|
}
|
|
956
|
-
this
|
|
957
|
-
this
|
|
958
|
-
this
|
|
959
|
-
this
|
|
985
|
+
this.#setBoolean(opts, 'dsmEnabled', options.dsmEnabled)
|
|
986
|
+
this.#setBoolean(opts, 'dynamicInstrumentation.enabled', options.dynamicInstrumentation?.enabled)
|
|
987
|
+
this.#setString(opts, 'dynamicInstrumentation.probeFile', options.dynamicInstrumentation?.probeFile)
|
|
988
|
+
this.#setArray(
|
|
960
989
|
opts,
|
|
961
990
|
'dynamicInstrumentation.redactedIdentifiers',
|
|
962
991
|
options.dynamicInstrumentation?.redactedIdentifiers
|
|
963
992
|
)
|
|
964
|
-
this
|
|
993
|
+
this.#setArray(
|
|
965
994
|
opts,
|
|
966
995
|
'dynamicInstrumentation.redactionExcludedIdentifiers',
|
|
967
996
|
options.dynamicInstrumentation?.redactionExcludedIdentifiers
|
|
968
997
|
)
|
|
969
998
|
opts['dynamicInstrumentation.uploadIntervalSeconds'] =
|
|
970
999
|
maybeFloat(options.dynamicInstrumentation?.uploadIntervalSeconds)
|
|
971
|
-
this
|
|
1000
|
+
this.#optsUnprocessed['dynamicInstrumentation.uploadIntervalSeconds'] =
|
|
972
1001
|
options.dynamicInstrumentation?.uploadIntervalSeconds
|
|
973
|
-
this
|
|
974
|
-
this
|
|
975
|
-
this
|
|
1002
|
+
this.#setString(opts, 'env', options.env || tags.env)
|
|
1003
|
+
this.#setBoolean(opts, 'experimental.aiguard.enabled', options.experimental?.aiguard?.enabled)
|
|
1004
|
+
this.#setString(opts, 'experimental.aiguard.endpoint', options.experimental?.aiguard?.endpoint)
|
|
976
1005
|
opts['experimental.aiguard.maxMessagesLength'] = maybeInt(options.experimental?.aiguard?.maxMessagesLength)
|
|
977
|
-
this
|
|
1006
|
+
this.#optsUnprocessed['experimental.aiguard.maxMessagesLength'] = options.experimental?.aiguard?.maxMessagesLength
|
|
978
1007
|
opts['experimental.aiguard.maxContentSize'] = maybeInt(options.experimental?.aiguard?.maxContentSize)
|
|
979
|
-
this
|
|
1008
|
+
this.#optsUnprocessed['experimental.aiguard.maxContentSize'] = options.experimental?.aiguard?.maxContentSize
|
|
980
1009
|
opts['experimental.aiguard.timeout'] = maybeInt(options.experimental?.aiguard?.timeout)
|
|
981
|
-
this
|
|
982
|
-
this
|
|
983
|
-
this
|
|
984
|
-
this
|
|
1010
|
+
this.#optsUnprocessed['experimental.aiguard.timeout'] = options.experimental?.aiguard?.timeout
|
|
1011
|
+
this.#setBoolean(opts, 'experimental.enableGetRumData', options.experimental?.enableGetRumData)
|
|
1012
|
+
this.#setString(opts, 'experimental.exporter', options.experimental?.exporter)
|
|
1013
|
+
this.#setBoolean(opts, 'experimental.flaggingProvider.enabled', options.experimental?.flaggingProvider?.enabled)
|
|
985
1014
|
opts.flushInterval = maybeInt(options.flushInterval)
|
|
986
|
-
this.
|
|
1015
|
+
this.#optsUnprocessed.flushInterval = options.flushInterval
|
|
987
1016
|
opts.flushMinSpans = maybeInt(options.flushMinSpans)
|
|
988
|
-
this.
|
|
989
|
-
this
|
|
990
|
-
this
|
|
1017
|
+
this.#optsUnprocessed.flushMinSpans = options.flushMinSpans
|
|
1018
|
+
this.#setArray(opts, 'headerTags', options.headerTags)
|
|
1019
|
+
this.#setString(opts, 'hostname', options.hostname)
|
|
991
1020
|
opts['iast.dbRowsToTaint'] = maybeInt(options.iast?.dbRowsToTaint)
|
|
992
|
-
this
|
|
993
|
-
this
|
|
1021
|
+
this.#setBoolean(opts, 'iast.deduplicationEnabled', options.iast && options.iast.deduplicationEnabled)
|
|
1022
|
+
this.#setBoolean(opts, 'iast.enabled',
|
|
994
1023
|
options.iast && (options.iast === true || options.iast.enabled === true))
|
|
995
1024
|
opts['iast.maxConcurrentRequests'] = maybeInt(options.iast?.maxConcurrentRequests)
|
|
996
|
-
this
|
|
1025
|
+
this.#optsUnprocessed['iast.maxConcurrentRequests'] = options.iast?.maxConcurrentRequests
|
|
997
1026
|
opts['iast.maxContextOperations'] = maybeInt(options.iast?.maxContextOperations)
|
|
998
|
-
this
|
|
999
|
-
this
|
|
1000
|
-
this
|
|
1001
|
-
this
|
|
1027
|
+
this.#optsUnprocessed['iast.maxContextOperations'] = options.iast?.maxContextOperations
|
|
1028
|
+
this.#setBoolean(opts, 'iast.redactionEnabled', options.iast?.redactionEnabled)
|
|
1029
|
+
this.#setString(opts, 'iast.redactionNamePattern', options.iast?.redactionNamePattern)
|
|
1030
|
+
this.#setString(opts, 'iast.redactionValuePattern', options.iast?.redactionValuePattern)
|
|
1002
1031
|
const iastRequestSampling = maybeInt(options.iast?.requestSampling)
|
|
1003
|
-
if (iastRequestSampling > -1 && iastRequestSampling < 101) {
|
|
1032
|
+
if (iastRequestSampling !== undefined && iastRequestSampling > -1 && iastRequestSampling < 101) {
|
|
1004
1033
|
opts['iast.requestSampling'] = iastRequestSampling
|
|
1005
|
-
this
|
|
1034
|
+
this.#optsUnprocessed['iast.requestSampling'] = options.iast?.requestSampling
|
|
1035
|
+
}
|
|
1036
|
+
if (DD_MAJOR < 6) {
|
|
1037
|
+
opts['iast.securityControlsConfiguration'] = options.iast?.securityControlsConfiguration
|
|
1006
1038
|
}
|
|
1007
|
-
opts
|
|
1008
|
-
this
|
|
1009
|
-
this
|
|
1010
|
-
this
|
|
1011
|
-
this
|
|
1012
|
-
this
|
|
1013
|
-
this
|
|
1014
|
-
this._setBoolean(opts, 'logInjection', options.logInjection)
|
|
1039
|
+
this.#setBoolean(opts, 'iast.stackTrace.enabled', options.iast?.stackTrace?.enabled)
|
|
1040
|
+
this.#setString(opts, 'iast.telemetryVerbosity', options.iast && options.iast.telemetryVerbosity)
|
|
1041
|
+
this.#setBoolean(opts, 'isCiVisibility', options.isCiVisibility)
|
|
1042
|
+
this.#setBoolean(opts, 'legacyBaggageEnabled', options.legacyBaggageEnabled)
|
|
1043
|
+
this.#setBoolean(opts, 'llmobs.agentlessEnabled', options.llmobs?.agentlessEnabled)
|
|
1044
|
+
this.#setString(opts, 'llmobs.mlApp', options.llmobs?.mlApp)
|
|
1045
|
+
this.#setBoolean(opts, 'logInjection', options.logInjection)
|
|
1015
1046
|
opts.lookup = options.lookup
|
|
1016
|
-
this
|
|
1017
|
-
this
|
|
1047
|
+
this.#setBoolean(opts, 'middlewareTracingEnabled', options.middlewareTracingEnabled)
|
|
1048
|
+
this.#setBoolean(opts, 'openAiLogsEnabled', options.openAiLogsEnabled)
|
|
1018
1049
|
opts.peerServiceMapping = options.peerServiceMapping
|
|
1019
|
-
this
|
|
1020
|
-
this
|
|
1050
|
+
this.#setBoolean(opts, 'plugins', options.plugins)
|
|
1051
|
+
this.#setString(opts, 'port', options.port)
|
|
1021
1052
|
const strProfiling = String(options.profiling)
|
|
1022
1053
|
if (['true', 'false', 'auto'].includes(strProfiling)) {
|
|
1023
|
-
this
|
|
1054
|
+
this.#setString(opts, 'profiling.enabled', strProfiling)
|
|
1024
1055
|
}
|
|
1025
|
-
this
|
|
1056
|
+
this.#setString(opts, 'protocolVersion', options.protocolVersion)
|
|
1026
1057
|
if (options.remoteConfig) {
|
|
1027
1058
|
opts['remoteConfig.pollInterval'] = maybeFloat(options.remoteConfig.pollInterval)
|
|
1028
|
-
this
|
|
1059
|
+
this.#optsUnprocessed['remoteConfig.pollInterval'] = options.remoteConfig.pollInterval
|
|
1029
1060
|
}
|
|
1030
|
-
this
|
|
1031
|
-
this
|
|
1032
|
-
this
|
|
1033
|
-
this
|
|
1034
|
-
this
|
|
1035
|
-
this
|
|
1036
|
-
this
|
|
1061
|
+
this.#setBoolean(opts, 'reportHostname', options.reportHostname)
|
|
1062
|
+
this.#setBoolean(opts, 'runtimeMetrics.enabled', options.runtimeMetrics?.enabled)
|
|
1063
|
+
this.#setBoolean(opts, 'runtimeMetrics.eventLoop', options.runtimeMetrics?.eventLoop)
|
|
1064
|
+
this.#setBoolean(opts, 'runtimeMetrics.gc', options.runtimeMetrics?.gc)
|
|
1065
|
+
this.#setBoolean(opts, 'runtimeMetricsRuntimeId', options.runtimeMetricsRuntimeId)
|
|
1066
|
+
this.#setArray(opts, 'sampler.spanSamplingRules', reformatSpanSamplingRules(options.spanSamplingRules))
|
|
1067
|
+
this.#setUnit(opts, 'sampleRate', options.sampleRate ?? options.ingestion.sampleRate)
|
|
1037
1068
|
opts['sampler.rateLimit'] = maybeInt(options.rateLimit ?? options.ingestion.rateLimit)
|
|
1038
|
-
this
|
|
1039
|
-
this
|
|
1069
|
+
this.#setSamplingRule(opts, 'sampler.rules', options.samplingRules)
|
|
1070
|
+
this.#setString(opts, 'service', options.service || tags.service)
|
|
1040
1071
|
opts.serviceMapping = options.serviceMapping
|
|
1041
|
-
this
|
|
1072
|
+
this.#setString(opts, 'site', options.site)
|
|
1042
1073
|
if (options.spanAttributeSchema) {
|
|
1043
|
-
this
|
|
1044
|
-
this.
|
|
1074
|
+
this.#setString(opts, 'spanAttributeSchema', validateNamingVersion(options.spanAttributeSchema))
|
|
1075
|
+
this.#optsUnprocessed.spanAttributeSchema = options.spanAttributeSchema
|
|
1076
|
+
}
|
|
1077
|
+
this.#setBoolean(opts, 'spanRemoveIntegrationFromService', options.spanRemoveIntegrationFromService)
|
|
1078
|
+
this.#setBoolean(opts, 'startupLogs', options.startupLogs)
|
|
1079
|
+
this.#setTags(opts, 'tags', tags)
|
|
1080
|
+
this.#setBoolean(opts, 'traceId128BitGenerationEnabled', options.traceId128BitGenerationEnabled)
|
|
1081
|
+
this.#setBoolean(opts, 'traceId128BitLoggingEnabled', options.traceId128BitLoggingEnabled)
|
|
1082
|
+
this.#setBoolean(opts, 'traceWebsocketMessagesEnabled', options.traceWebsocketMessagesEnabled)
|
|
1083
|
+
this.#setBoolean(opts, 'traceWebsocketMessagesInheritSampling', options.traceWebsocketMessagesInheritSampling)
|
|
1084
|
+
this.#setBoolean(opts, 'traceWebsocketMessagesSeparateTraces', options.traceWebsocketMessagesSeparateTraces)
|
|
1085
|
+
this.#setString(opts, 'version', options.version || tags.version)
|
|
1086
|
+
this.#setBoolean(opts, 'inferredProxyServicesEnabled', options.inferredProxyServicesEnabled)
|
|
1087
|
+
this.#setBoolean(opts, 'graphqlErrorExtensions', options.graphqlErrorExtensions)
|
|
1088
|
+
this.#setBoolean(opts, 'trace.nativeSpanEvents', options.trace?.nativeSpanEvents)
|
|
1089
|
+
if (options.tracePropagationStyle) {
|
|
1090
|
+
this.#setArray(opts, 'tracePropagationStyle.inject',
|
|
1091
|
+
normalizePropagationStyle(options.tracePropagationStyle.inject ?? options.tracePropagationStyle))
|
|
1092
|
+
this.#setArray(opts, 'tracePropagationStyle.extract',
|
|
1093
|
+
normalizePropagationStyle(options.tracePropagationStyle.extract ?? options.tracePropagationStyle))
|
|
1045
1094
|
}
|
|
1046
|
-
this._setBoolean(opts, 'spanRemoveIntegrationFromService', options.spanRemoveIntegrationFromService)
|
|
1047
|
-
this._setBoolean(opts, 'startupLogs', options.startupLogs)
|
|
1048
|
-
this._setTags(opts, 'tags', tags)
|
|
1049
|
-
this._setBoolean(opts, 'traceId128BitGenerationEnabled', options.traceId128BitGenerationEnabled)
|
|
1050
|
-
this._setBoolean(opts, 'traceId128BitLoggingEnabled', options.traceId128BitLoggingEnabled)
|
|
1051
|
-
this._setBoolean(opts, 'traceWebsocketMessagesEnabled', options.traceWebsocketMessagesEnabled)
|
|
1052
|
-
this._setBoolean(opts, 'traceWebsocketMessagesInheritSampling', options.traceWebsocketMessagesInheritSampling)
|
|
1053
|
-
this._setBoolean(opts, 'traceWebsocketMessagesSeparateTraces', options.traceWebsocketMessagesSeparateTraces)
|
|
1054
|
-
this._setString(opts, 'version', options.version || tags.version)
|
|
1055
|
-
this._setBoolean(opts, 'inferredProxyServicesEnabled', options.inferredProxyServicesEnabled)
|
|
1056
|
-
this._setBoolean(opts, 'graphqlErrorExtensions', options.graphqlErrorExtensions)
|
|
1057
|
-
this._setBoolean(opts, 'trace.nativeSpanEvents', options.trace?.nativeSpanEvents)
|
|
1058
1095
|
|
|
1059
1096
|
// For LLMObs, we want the environment variable to take precedence over the options.
|
|
1060
1097
|
// This is reliant on environment config being set before options.
|
|
1061
1098
|
// This is to make sure the origins of each value are tracked appropriately for telemetry.
|
|
1062
1099
|
// We'll only set `llmobs.enabled` on the opts when it's not set on the environment, and options.llmobs is provided.
|
|
1063
|
-
const llmobsEnabledEnv = this
|
|
1100
|
+
const llmobsEnabledEnv = this.#env['llmobs.enabled']
|
|
1064
1101
|
if (llmobsEnabledEnv == null && options.llmobs) {
|
|
1065
|
-
this
|
|
1102
|
+
this.#setBoolean(opts, 'llmobs.enabled', !!options.llmobs)
|
|
1066
1103
|
}
|
|
1067
1104
|
}
|
|
1068
1105
|
|
|
1069
|
-
|
|
1070
|
-
return this.
|
|
1106
|
+
#isCiVisibility () {
|
|
1107
|
+
return this.#optionsArg.isCiVisibility ?? this.#defaults.isCiVisibility
|
|
1071
1108
|
}
|
|
1072
1109
|
|
|
1073
|
-
|
|
1074
|
-
return
|
|
1110
|
+
#isCiVisibilityItrEnabled () {
|
|
1111
|
+
return getEnv('DD_CIVISIBILITY_ITR_ENABLED') ?? true
|
|
1075
1112
|
}
|
|
1076
1113
|
|
|
1077
|
-
|
|
1078
|
-
const DD_CIVISIBILITY_AGENTLESS_URL =
|
|
1114
|
+
#getHostname () {
|
|
1115
|
+
const DD_CIVISIBILITY_AGENTLESS_URL = getEnv('DD_CIVISIBILITY_AGENTLESS_URL')
|
|
1079
1116
|
const url = DD_CIVISIBILITY_AGENTLESS_URL
|
|
1080
1117
|
? new URL(DD_CIVISIBILITY_AGENTLESS_URL)
|
|
1081
|
-
: getAgentUrl(this._getTraceAgentUrl(), this
|
|
1082
|
-
const DD_AGENT_HOST = this.
|
|
1083
|
-
|
|
1118
|
+
: getAgentUrl(this._getTraceAgentUrl(), this.#optionsArg)
|
|
1119
|
+
const DD_AGENT_HOST = this.#optionsArg.hostname ??
|
|
1120
|
+
getEnv('DD_AGENT_HOST') ??
|
|
1084
1121
|
defaults.hostname
|
|
1085
1122
|
return DD_AGENT_HOST || url?.hostname
|
|
1086
1123
|
}
|
|
1087
1124
|
|
|
1088
|
-
|
|
1125
|
+
#getSpanComputePeerService () {
|
|
1089
1126
|
const DD_TRACE_SPAN_ATTRIBUTE_SCHEMA = validateNamingVersion(
|
|
1090
|
-
this.
|
|
1091
|
-
|
|
1127
|
+
this.#optionsArg.spanAttributeSchema ??
|
|
1128
|
+
getEnv('DD_TRACE_SPAN_ATTRIBUTE_SCHEMA')
|
|
1092
1129
|
)
|
|
1093
1130
|
|
|
1094
1131
|
const peerServiceSet = (
|
|
1095
|
-
this.
|
|
1096
|
-
|
|
1132
|
+
this.#optionsArg.hasOwnProperty('spanComputePeerService') ||
|
|
1133
|
+
getEnv('DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED') !== undefined
|
|
1097
1134
|
)
|
|
1098
|
-
const peerServiceValue = this.
|
|
1099
|
-
|
|
1135
|
+
const peerServiceValue = this.#optionsArg.spanComputePeerService ??
|
|
1136
|
+
getEnv('DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED')
|
|
1100
1137
|
|
|
1101
1138
|
const spanComputePeerService = (
|
|
1102
1139
|
DD_TRACE_SPAN_ATTRIBUTE_SCHEMA === 'v0'
|
|
@@ -1109,101 +1146,81 @@ class Config {
|
|
|
1109
1146
|
return spanComputePeerService
|
|
1110
1147
|
}
|
|
1111
1148
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
_isCiVisibilityManualApiEnabled () {
|
|
1117
|
-
return getEnvironmentVariable('DD_CIVISIBILITY_MANUAL_API_ENABLED') ?? true
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
_isTraceStatsComputationEnabled () {
|
|
1121
|
-
const apmTracingEnabled = this._options.apmTracingEnabled !== false &&
|
|
1122
|
-
this._env.apmTracingEnabled !== false
|
|
1149
|
+
#isTraceStatsComputationEnabled () {
|
|
1150
|
+
const apmTracingEnabled = this.#options.apmTracingEnabled !== false &&
|
|
1151
|
+
this.#env.apmTracingEnabled !== false
|
|
1123
1152
|
|
|
1124
1153
|
return apmTracingEnabled && (
|
|
1125
|
-
this.
|
|
1126
|
-
|
|
1154
|
+
this.#optionsArg.stats ??
|
|
1155
|
+
getEnv('DD_TRACE_STATS_COMPUTATION_ENABLED') ??
|
|
1127
1156
|
(getIsGCPFunction() || getIsAzureFunction())
|
|
1128
1157
|
)
|
|
1129
1158
|
}
|
|
1130
1159
|
|
|
1131
1160
|
_getTraceAgentUrl () {
|
|
1132
|
-
return this.
|
|
1133
|
-
|
|
1161
|
+
return this.#optionsArg.url ??
|
|
1162
|
+
getEnv('DD_TRACE_AGENT_URL') ??
|
|
1134
1163
|
null
|
|
1135
1164
|
}
|
|
1136
1165
|
|
|
1137
1166
|
// handles values calculated from a mixture of options and env vars
|
|
1138
|
-
|
|
1139
|
-
const calc =
|
|
1167
|
+
#applyCalculated () {
|
|
1168
|
+
const calc = this.#calculated
|
|
1140
1169
|
|
|
1141
|
-
const
|
|
1142
|
-
DD_CIVISIBILITY_AGENTLESS_URL,
|
|
1143
|
-
DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED,
|
|
1144
|
-
DD_CIVISIBILITY_FLAKY_RETRY_ENABLED,
|
|
1145
|
-
DD_CIVISIBILITY_FLAKY_RETRY_COUNT,
|
|
1146
|
-
DD_TEST_SESSION_NAME,
|
|
1147
|
-
DD_AGENTLESS_LOG_SUBMISSION_ENABLED,
|
|
1148
|
-
DD_TEST_FAILED_TEST_REPLAY_ENABLED,
|
|
1149
|
-
DD_TEST_MANAGEMENT_ENABLED,
|
|
1150
|
-
DD_TEST_MANAGEMENT_ATTEMPT_TO_FIX_RETRIES,
|
|
1151
|
-
DD_CIVISIBILITY_IMPACTED_TESTS_DETECTION_ENABLED
|
|
1152
|
-
} = getEnvironmentVariables()
|
|
1170
|
+
const DD_CIVISIBILITY_AGENTLESS_URL = getEnv('DD_CIVISIBILITY_AGENTLESS_URL')
|
|
1153
1171
|
|
|
1154
1172
|
calc.url = DD_CIVISIBILITY_AGENTLESS_URL
|
|
1155
1173
|
? new URL(DD_CIVISIBILITY_AGENTLESS_URL)
|
|
1156
|
-
: getAgentUrl(this._getTraceAgentUrl(), this
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
this
|
|
1160
|
-
|
|
1161
|
-
this
|
|
1162
|
-
|
|
1163
|
-
this
|
|
1164
|
-
this
|
|
1165
|
-
this
|
|
1166
|
-
this
|
|
1167
|
-
|
|
1168
|
-
calc
|
|
1169
|
-
|
|
1174
|
+
: getAgentUrl(this._getTraceAgentUrl(), this.#optionsArg)
|
|
1175
|
+
|
|
1176
|
+
if (this.#isCiVisibility()) {
|
|
1177
|
+
this.#setBoolean(calc, 'isEarlyFlakeDetectionEnabled',
|
|
1178
|
+
getEnv('DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED') ?? true)
|
|
1179
|
+
this.#setBoolean(calc, 'isFlakyTestRetriesEnabled', getEnv('DD_CIVISIBILITY_FLAKY_RETRY_ENABLED') ?? true)
|
|
1180
|
+
calc.flakyTestRetriesCount = maybeInt(getEnv('DD_CIVISIBILITY_FLAKY_RETRY_COUNT')) ?? 5
|
|
1181
|
+
this.#setBoolean(calc, 'isIntelligentTestRunnerEnabled', isTrue(this.#isCiVisibilityItrEnabled()))
|
|
1182
|
+
this.#setBoolean(calc, 'isManualApiEnabled', !isFalse(getEnv('DD_CIVISIBILITY_MANUAL_API_ENABLED')))
|
|
1183
|
+
this.#setString(calc, 'ciVisibilityTestSessionName', getEnv('DD_TEST_SESSION_NAME'))
|
|
1184
|
+
this.#setBoolean(calc, 'ciVisAgentlessLogSubmissionEnabled',
|
|
1185
|
+
isTrue(getEnv('DD_AGENTLESS_LOG_SUBMISSION_ENABLED')))
|
|
1186
|
+
this.#setBoolean(calc, 'isTestDynamicInstrumentationEnabled',
|
|
1187
|
+
!isFalse(getEnv('DD_TEST_FAILED_TEST_REPLAY_ENABLED')))
|
|
1188
|
+
this.#setBoolean(calc, 'isServiceUserProvided', !!this.#env.service)
|
|
1189
|
+
this.#setBoolean(calc, 'isTestManagementEnabled', !isFalse(getEnv('DD_TEST_MANAGEMENT_ENABLED')))
|
|
1190
|
+
calc.testManagementAttemptToFixRetries = maybeInt(getEnv('DD_TEST_MANAGEMENT_ATTEMPT_TO_FIX_RETRIES')) ?? 20
|
|
1191
|
+
this.#setBoolean(calc, 'isImpactedTestsEnabled',
|
|
1192
|
+
!isFalse(getEnv('DD_CIVISIBILITY_IMPACTED_TESTS_DETECTION_ENABLED')))
|
|
1170
1193
|
}
|
|
1171
1194
|
|
|
1172
1195
|
// Disable log injection when OTEL logs are enabled
|
|
1173
1196
|
// OTEL logs and DD log injection are mutually exclusive
|
|
1174
|
-
if (this.
|
|
1175
|
-
this
|
|
1197
|
+
if (this.#env.otelLogsEnabled) {
|
|
1198
|
+
this.#setBoolean(calc, 'logInjection', false)
|
|
1176
1199
|
}
|
|
1177
1200
|
|
|
1178
|
-
calc['dogstatsd.hostname'] = this
|
|
1201
|
+
calc['dogstatsd.hostname'] = this.#getHostname()
|
|
1179
1202
|
|
|
1180
1203
|
// Compute OTLP logs URL to send payloads to the active Datadog Agent
|
|
1181
|
-
const agentHostname = this
|
|
1204
|
+
const agentHostname = this.#getHostname()
|
|
1182
1205
|
calc.otelLogsUrl = `http://${agentHostname}:${DEFAULT_OTLP_PORT}`
|
|
1183
1206
|
calc.otelUrl = `http://${agentHostname}:${DEFAULT_OTLP_PORT}`
|
|
1184
1207
|
|
|
1185
|
-
this
|
|
1186
|
-
calc.isIntelligentTestRunnerEnabled && !isFalse(
|
|
1187
|
-
|
|
1188
|
-
this
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
'inject',
|
|
1192
|
-
this._optionsArg.tracePropagationStyle
|
|
1193
|
-
)
|
|
1194
|
-
calc['tracePropagationStyle.extract'] = propagationStyle(
|
|
1195
|
-
'extract',
|
|
1196
|
-
this._optionsArg.tracePropagationStyle
|
|
1197
|
-
)
|
|
1208
|
+
this.#setBoolean(calc, 'isGitUploadEnabled',
|
|
1209
|
+
calc.isIntelligentTestRunnerEnabled && !isFalse(getEnv('DD_CIVISIBILITY_GIT_UPLOAD_ENABLED')))
|
|
1210
|
+
|
|
1211
|
+
this.#setBoolean(calc, 'spanComputePeerService', this.#getSpanComputePeerService())
|
|
1212
|
+
this.#setBoolean(calc, 'stats.enabled', this.#isTraceStatsComputationEnabled())
|
|
1213
|
+
const defaultPropagationStyle = this.#getDefaultPropagationStyle(this.#optionsArg)
|
|
1198
1214
|
if (defaultPropagationStyle.length > 2) {
|
|
1199
|
-
|
|
1200
|
-
|
|
1215
|
+
// b3 was added, so update defaults to include it
|
|
1216
|
+
// This will only be used if no other source (options, env, stable config) set the value
|
|
1217
|
+
calc['tracePropagationStyle.inject'] = defaultPropagationStyle
|
|
1218
|
+
calc['tracePropagationStyle.extract'] = defaultPropagationStyle
|
|
1201
1219
|
}
|
|
1202
1220
|
}
|
|
1203
1221
|
|
|
1204
|
-
|
|
1205
|
-
const opts =
|
|
1206
|
-
setHiddenProperty(this, '_remoteUnprocessed', {})
|
|
1222
|
+
#applyRemote (options) {
|
|
1223
|
+
const opts = this.#remote
|
|
1207
1224
|
const tags = {}
|
|
1208
1225
|
const headerTags = options.tracing_header_tags
|
|
1209
1226
|
? options.tracing_header_tags.map(tag => {
|
|
@@ -1214,20 +1231,20 @@ class Config {
|
|
|
1214
1231
|
tagger.add(tags, options.tracing_tags)
|
|
1215
1232
|
if (Object.keys(tags).length) tags['runtime-id'] = runtimeId
|
|
1216
1233
|
|
|
1217
|
-
this
|
|
1218
|
-
this
|
|
1234
|
+
this.#setUnit(opts, 'sampleRate', options.tracing_sampling_rate)
|
|
1235
|
+
this.#setBoolean(opts, 'logInjection', options.log_injection_enabled)
|
|
1219
1236
|
opts.headerTags = headerTags
|
|
1220
|
-
this
|
|
1221
|
-
this
|
|
1222
|
-
this
|
|
1223
|
-
this
|
|
1237
|
+
this.#setTags(opts, 'tags', tags)
|
|
1238
|
+
this.#setBoolean(opts, 'tracing', options.tracing_enabled)
|
|
1239
|
+
this.#remoteUnprocessed['sampler.rules'] = options.tracing_sampling_rules
|
|
1240
|
+
this.#setSamplingRule(opts, 'sampler.rules', this.#reformatTags(options.tracing_sampling_rules))
|
|
1224
1241
|
}
|
|
1225
1242
|
|
|
1226
|
-
|
|
1243
|
+
#reformatTags (samplingRules) {
|
|
1227
1244
|
for (const rule of (samplingRules || [])) {
|
|
1228
1245
|
const reformattedTags = {}
|
|
1229
1246
|
if (rule.tags) {
|
|
1230
|
-
for (const tag of
|
|
1247
|
+
for (const tag of rule.tags) {
|
|
1231
1248
|
reformattedTags[tag.key] = tag.value_glob
|
|
1232
1249
|
}
|
|
1233
1250
|
rule.tags = reformattedTags
|
|
@@ -1236,7 +1253,7 @@ class Config {
|
|
|
1236
1253
|
return samplingRules
|
|
1237
1254
|
}
|
|
1238
1255
|
|
|
1239
|
-
|
|
1256
|
+
#setBoolean (obj, name, value) {
|
|
1240
1257
|
if (value === undefined || value === null) {
|
|
1241
1258
|
obj[name] = value
|
|
1242
1259
|
} else if (isTrue(value)) {
|
|
@@ -1246,7 +1263,7 @@ class Config {
|
|
|
1246
1263
|
}
|
|
1247
1264
|
}
|
|
1248
1265
|
|
|
1249
|
-
|
|
1266
|
+
#setUnit (obj, name, value) {
|
|
1250
1267
|
if (value === null || value === undefined) {
|
|
1251
1268
|
obj[name] = value
|
|
1252
1269
|
return
|
|
@@ -1260,7 +1277,7 @@ class Config {
|
|
|
1260
1277
|
}
|
|
1261
1278
|
}
|
|
1262
1279
|
|
|
1263
|
-
|
|
1280
|
+
#setArray (obj, name, value) {
|
|
1264
1281
|
if (value == null) {
|
|
1265
1282
|
obj[name] = null
|
|
1266
1283
|
return
|
|
@@ -1279,7 +1296,7 @@ class Config {
|
|
|
1279
1296
|
}
|
|
1280
1297
|
}
|
|
1281
1298
|
|
|
1282
|
-
|
|
1299
|
+
#setIntegerRangeSet (obj, name, value) {
|
|
1283
1300
|
if (value == null) {
|
|
1284
1301
|
obj[name] = null
|
|
1285
1302
|
return
|
|
@@ -1300,7 +1317,7 @@ class Config {
|
|
|
1300
1317
|
obj[name] = result
|
|
1301
1318
|
}
|
|
1302
1319
|
|
|
1303
|
-
|
|
1320
|
+
#setSamplingRule (obj, name, value) {
|
|
1304
1321
|
if (value == null) {
|
|
1305
1322
|
obj[name] = null
|
|
1306
1323
|
return
|
|
@@ -1320,11 +1337,11 @@ class Config {
|
|
|
1320
1337
|
}
|
|
1321
1338
|
}
|
|
1322
1339
|
|
|
1323
|
-
|
|
1340
|
+
#setString (obj, name, value) {
|
|
1324
1341
|
obj[name] = value ? String(value) : undefined // unset for empty strings
|
|
1325
1342
|
}
|
|
1326
1343
|
|
|
1327
|
-
|
|
1344
|
+
#setTags (obj, name, value) {
|
|
1328
1345
|
if (!value || Object.keys(value).length === 0) {
|
|
1329
1346
|
obj[name] = null
|
|
1330
1347
|
return
|
|
@@ -1333,7 +1350,7 @@ class Config {
|
|
|
1333
1350
|
obj[name] = value
|
|
1334
1351
|
}
|
|
1335
1352
|
|
|
1336
|
-
|
|
1353
|
+
#setAndTrackChange ({ name, value, origin, unprocessedValue, changes }) {
|
|
1337
1354
|
set(this, name, value)
|
|
1338
1355
|
|
|
1339
1356
|
if (!changeTracker[name]) {
|
|
@@ -1358,21 +1375,21 @@ class Config {
|
|
|
1358
1375
|
// TODO: Move change tracking to telemetry.
|
|
1359
1376
|
// for telemetry reporting, `name`s in `containers` need to be keys from:
|
|
1360
1377
|
// https://github.com/DataDog/dd-go/blob/prod/trace/apps/tracer-telemetry-intake/telemetry-payload/static/config_norm_rules.json
|
|
1361
|
-
|
|
1378
|
+
#merge () {
|
|
1362
1379
|
const changes = []
|
|
1380
|
+
const sources = this.#getSourcesInOrder()
|
|
1363
1381
|
|
|
1364
|
-
for (const name
|
|
1382
|
+
for (const name of Object.keys(this.#defaults)) {
|
|
1365
1383
|
// Use reverse order for merge (lowest priority first)
|
|
1366
|
-
for (let i =
|
|
1367
|
-
const {
|
|
1368
|
-
const container = this[containerProperty]
|
|
1384
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1385
|
+
const { container, origin, unprocessed } = sources[i]
|
|
1369
1386
|
const value = container[name]
|
|
1370
|
-
if (value != null || container === this
|
|
1371
|
-
this
|
|
1387
|
+
if (value != null || container === this.#defaults) {
|
|
1388
|
+
this.#setAndTrackChange({
|
|
1372
1389
|
name,
|
|
1373
1390
|
value,
|
|
1374
1391
|
origin,
|
|
1375
|
-
unprocessedValue:
|
|
1392
|
+
unprocessedValue: unprocessed?.[name],
|
|
1376
1393
|
changes
|
|
1377
1394
|
})
|
|
1378
1395
|
}
|
|
@@ -1383,34 +1400,33 @@ class Config {
|
|
|
1383
1400
|
}
|
|
1384
1401
|
|
|
1385
1402
|
getOrigin (name) {
|
|
1386
|
-
for (const {
|
|
1387
|
-
const container = this[containerProperty]
|
|
1403
|
+
for (const { container, origin } of this.#getSourcesInOrder()) {
|
|
1388
1404
|
const value = container[name]
|
|
1389
|
-
if (value != null || container === this
|
|
1405
|
+
if (value != null || container === this.#defaults) {
|
|
1390
1406
|
return origin
|
|
1391
1407
|
}
|
|
1392
1408
|
}
|
|
1393
1409
|
}
|
|
1394
1410
|
|
|
1395
|
-
|
|
1411
|
+
#loadGitMetadata (envs) {
|
|
1396
1412
|
// try to read Git metadata from the environment variables
|
|
1397
1413
|
this.repositoryUrl = removeUserSensitiveInfo(
|
|
1398
|
-
|
|
1414
|
+
envs.DD_GIT_REPOSITORY_URL ??
|
|
1399
1415
|
this.tags[GIT_REPOSITORY_URL]
|
|
1400
1416
|
)
|
|
1401
|
-
this.commitSHA =
|
|
1417
|
+
this.commitSHA = envs.DD_GIT_COMMIT_SHA ??
|
|
1402
1418
|
this.tags[GIT_COMMIT_SHA]
|
|
1403
1419
|
|
|
1404
1420
|
// otherwise, try to read Git metadata from the git.properties file
|
|
1405
1421
|
if (!this.repositoryUrl || !this.commitSHA) {
|
|
1406
|
-
const DD_GIT_PROPERTIES_FILE =
|
|
1422
|
+
const DD_GIT_PROPERTIES_FILE = envs.DD_GIT_PROPERTIES_FILE ??
|
|
1407
1423
|
`${process.cwd()}/git.properties`
|
|
1408
1424
|
let gitPropertiesString
|
|
1409
1425
|
try {
|
|
1410
1426
|
gitPropertiesString = fs.readFileSync(DD_GIT_PROPERTIES_FILE, 'utf8')
|
|
1411
1427
|
} catch (e) {
|
|
1412
1428
|
// Only log error if the user has set a git.properties path
|
|
1413
|
-
if (
|
|
1429
|
+
if (envs.DD_GIT_PROPERTIES_FILE) {
|
|
1414
1430
|
log.error('Error reading DD_GIT_PROPERTIES_FILE: %s', DD_GIT_PROPERTIES_FILE, e)
|
|
1415
1431
|
}
|
|
1416
1432
|
}
|
|
@@ -1422,7 +1438,7 @@ class Config {
|
|
|
1422
1438
|
}
|
|
1423
1439
|
// otherwise, try to read Git metadata from the .git/ folder
|
|
1424
1440
|
if (!this.repositoryUrl || !this.commitSHA) {
|
|
1425
|
-
const DD_GIT_FOLDER_PATH =
|
|
1441
|
+
const DD_GIT_FOLDER_PATH = envs.DD_GIT_FOLDER_PATH ??
|
|
1426
1442
|
path.join(process.cwd(), '.git')
|
|
1427
1443
|
if (!this.repositoryUrl) {
|
|
1428
1444
|
// try to read git config (repository URL)
|
|
@@ -1434,7 +1450,7 @@ class Config {
|
|
|
1434
1450
|
}
|
|
1435
1451
|
} catch (e) {
|
|
1436
1452
|
// Only log error if the user has set a .git/ path
|
|
1437
|
-
if (
|
|
1453
|
+
if (envs.DD_GIT_FOLDER_PATH) {
|
|
1438
1454
|
log.error('Error reading git config: %s', gitConfigPath, e)
|
|
1439
1455
|
}
|
|
1440
1456
|
}
|
|
@@ -1483,21 +1499,12 @@ function getAgentUrl (url, options) {
|
|
|
1483
1499
|
if (
|
|
1484
1500
|
!options.hostname &&
|
|
1485
1501
|
!options.port &&
|
|
1486
|
-
!
|
|
1487
|
-
!
|
|
1502
|
+
!getEnv('DD_AGENT_HOST') &&
|
|
1503
|
+
!getEnv('DD_TRACE_AGENT_PORT') &&
|
|
1488
1504
|
fs.existsSync('/var/run/datadog/apm.socket')
|
|
1489
1505
|
) {
|
|
1490
1506
|
return new URL('unix:///var/run/datadog/apm.socket')
|
|
1491
1507
|
}
|
|
1492
1508
|
}
|
|
1493
1509
|
|
|
1494
|
-
function setHiddenProperty (obj, name, value) {
|
|
1495
|
-
Object.defineProperty(obj, name, {
|
|
1496
|
-
value,
|
|
1497
|
-
enumerable: false,
|
|
1498
|
-
writable: true
|
|
1499
|
-
})
|
|
1500
|
-
return obj[name]
|
|
1501
|
-
}
|
|
1502
|
-
|
|
1503
1510
|
module.exports = Config
|