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