diff --git a/packages/dd-trace/src/config.js b/packages/dd-trace/src/config.js index 09ce9d5fd66..8dd63cccdf6 100644 --- a/packages/dd-trace/src/config.js +++ b/packages/dd-trace/src/config.js @@ -472,9 +472,9 @@ class Config { this._setValue(defaults, 'dogstatsd.hostname', '127.0.0.1') this._setValue(defaults, 'dogstatsd.port', '8125') this._setValue(defaults, 'dsmEnabled', false) - this._setValue(defaults, 'dynamicInstrumentationEnabled', false) - this._setValue(defaults, 'dynamicInstrumentationRedactedIdentifiers', []) - this._setValue(defaults, 'dynamicInstrumentationRedactionExcludedIdentifiers', []) + this._setValue(defaults, 'dynamicInstrumentation.enabled', false) + this._setValue(defaults, 'dynamicInstrumentation.redactedIdentifiers', []) + this._setValue(defaults, 'dynamicInstrumentation.redactionExcludedIdentifiers', []) this._setValue(defaults, 'env', undefined) this._setValue(defaults, 'experimental.enableGetRumData', false) this._setValue(defaults, 'experimental.exporter', undefined) @@ -750,11 +750,11 @@ class Config { this._setString(env, 'dogstatsd.hostname', DD_DOGSTATSD_HOST || DD_DOGSTATSD_HOSTNAME) this._setString(env, 'dogstatsd.port', DD_DOGSTATSD_PORT) this._setBoolean(env, 'dsmEnabled', DD_DATA_STREAMS_ENABLED) - this._setBoolean(env, 'dynamicInstrumentationEnabled', DD_DYNAMIC_INSTRUMENTATION_ENABLED) - this._setArray(env, 'dynamicInstrumentationRedactedIdentifiers', DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS) + this._setBoolean(env, 'dynamicInstrumentation.enabled', DD_DYNAMIC_INSTRUMENTATION_ENABLED) + this._setArray(env, 'dynamicInstrumentation.redactedIdentifiers', DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS) this._setArray( env, - 'dynamicInstrumentationRedactionExcludedIdentifiers', + 'dynamicInstrumentation.redactionExcludedIdentifiers', DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS ) this._setString(env, 'env', DD_ENV || tags.env) @@ -936,16 +936,16 @@ class Config { this._setString(opts, 'dogstatsd.port', options.dogstatsd.port) } this._setBoolean(opts, 'dsmEnabled', options.dsmEnabled) - this._setBoolean(opts, 'dynamicInstrumentationEnabled', options.experimental?.dynamicInstrumentationEnabled) + this._setBoolean(opts, 'dynamicInstrumentation.enabled', options.dynamicInstrumentation?.enabled) this._setArray( opts, - 'dynamicInstrumentationRedactedIdentifiers', - options.experimental?.dynamicInstrumentationRedactedIdentifiers + 'dynamicInstrumentation.redactedIdentifiers', + options.dynamicInstrumentation?.redactedIdentifiers ) this._setArray( opts, - 'dynamicInstrumentationRedactionExcludedIdentifiers', - options.experimental?.dynamicInstrumentationRedactionExcludedIdentifiers + 'dynamicInstrumentation.redactionExcludedIdentifiers', + options.dynamicInstrumentation?.redactionExcludedIdentifiers ) this._setString(opts, 'env', options.env || tags.env) this._setBoolean(opts, 'experimental.enableGetRumData', options.experimental?.enableGetRumData) diff --git a/packages/dd-trace/src/debugger/devtools_client/config.js b/packages/dd-trace/src/debugger/devtools_client/config.js index 4880bbe5fdb..663bd5c9419 100644 --- a/packages/dd-trace/src/debugger/devtools_client/config.js +++ b/packages/dd-trace/src/debugger/devtools_client/config.js @@ -5,8 +5,7 @@ const { format } = require('node:url') const log = require('../../log') const config = module.exports = { - dynamicInstrumentationRedactedIdentifiers: parentConfig.dynamicInstrumentationRedactedIdentifiers, - dynamicInstrumentationRedactionExcludedIdentifiers: parentConfig.dynamicInstrumentationRedactionExcludedIdentifiers, + dynamicInstrumentation: parentConfig.dynamicInstrumentation, runtimeId: parentConfig.tags['runtime-id'], service: parentConfig.service, commitSHA: parentConfig.commitSHA, diff --git a/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js b/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js index 5ccb58f4053..e3b16272a9e 100644 --- a/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +++ b/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js @@ -2,7 +2,8 @@ const config = require('../config') -const excludedIdentifiers = config.dynamicInstrumentationRedactionExcludedIdentifiers.map((name) => normalizeName(name)) +const excludedIdentifiers = config.dynamicInstrumentation.redactionExcludedIdentifiers + .map((name) => normalizeName(name)) const REDACTED_IDENTIFIERS = new Set( [ @@ -99,7 +100,7 @@ const REDACTED_IDENTIFIERS = new Set( 'x_forwarded_for', 'x_real_ip', 'XSRF-TOKEN', - ...config.dynamicInstrumentationRedactedIdentifiers + ...config.dynamicInstrumentation.redactedIdentifiers ] .map((name) => normalizeName(name)) .filter((name) => excludedIdentifiers.includes(name) === false) diff --git a/packages/dd-trace/src/proxy.js b/packages/dd-trace/src/proxy.js index 874945eeecc..a5d91d7761e 100644 --- a/packages/dd-trace/src/proxy.js +++ b/packages/dd-trace/src/proxy.js @@ -119,7 +119,7 @@ class Tracer extends NoopProxy { this._flare.module.send(conf.args) }) - if (config.dynamicInstrumentationEnabled) { + if (config.dynamicInstrumentation.enabled) { DynamicInstrumentation.start(config, rc) } } diff --git a/packages/dd-trace/test/config.spec.js b/packages/dd-trace/test/config.spec.js index 49e691afae8..a7a97aa1b58 100644 --- a/packages/dd-trace/test/config.spec.js +++ b/packages/dd-trace/test/config.spec.js @@ -231,9 +231,9 @@ describe('Config', () => { expect(config).to.have.property('scope', undefined) expect(config).to.have.property('logLevel', 'debug') expect(config).to.have.nested.property('codeOriginForSpans.enabled', false) - expect(config).to.have.property('dynamicInstrumentationEnabled', false) - expect(config).to.have.deep.property('dynamicInstrumentationRedactedIdentifiers', []) - expect(config).to.have.deep.property('dynamicInstrumentationRedactionExcludedIdentifiers', []) + expect(config).to.have.nested.property('dynamicInstrumentation.enabled', false) + expect(config).to.have.nested.deep.property('dynamicInstrumentation.redactedIdentifiers', []) + expect(config).to.have.nested.deep.property('dynamicInstrumentation.redactionExcludedIdentifiers', []) expect(config).to.have.property('traceId128BitGenerationEnabled', true) expect(config).to.have.property('traceId128BitLoggingEnabled', false) expect(config).to.have.property('spanAttributeSchema', 'v0') @@ -315,9 +315,9 @@ describe('Config', () => { { name: 'dogstatsd.hostname', value: '127.0.0.1', origin: 'calculated' }, { name: 'dogstatsd.port', value: '8125', origin: 'default' }, { name: 'dsmEnabled', value: false, origin: 'default' }, - { name: 'dynamicInstrumentationEnabled', value: false, origin: 'default' }, - { name: 'dynamicInstrumentationRedactedIdentifiers', value: [], origin: 'default' }, - { name: 'dynamicInstrumentationRedactionExcludedIdentifiers', value: [], origin: 'default' }, + { name: 'dynamicInstrumentation.enabled', value: false, origin: 'default' }, + { name: 'dynamicInstrumentation.redactedIdentifiers', value: [], origin: 'default' }, + { name: 'dynamicInstrumentation.redactionExcludedIdentifiers', value: [], origin: 'default' }, { name: 'env', value: undefined, origin: 'default' }, { name: 'experimental.enableGetRumData', value: false, origin: 'default' }, { name: 'experimental.exporter', value: undefined, origin: 'default' }, @@ -557,9 +557,9 @@ describe('Config', () => { expect(config).to.have.property('runtimeMetrics', true) expect(config).to.have.property('reportHostname', true) expect(config).to.have.nested.property('codeOriginForSpans.enabled', true) - expect(config).to.have.property('dynamicInstrumentationEnabled', true) - expect(config).to.have.deep.property('dynamicInstrumentationRedactedIdentifiers', ['foo', 'bar']) - expect(config).to.have.deep.property('dynamicInstrumentationRedactionExcludedIdentifiers', ['a', 'b', 'c']) + expect(config).to.have.nested.property('dynamicInstrumentation.enabled', true) + expect(config).to.have.nested.deep.property('dynamicInstrumentation.redactedIdentifiers', ['foo', 'bar']) + expect(config).to.have.nested.deep.property('dynamicInstrumentation.redactionExcludedIdentifiers', ['a', 'b', 'c']) expect(config).to.have.property('env', 'test') expect(config).to.have.property('sampleRate', 0.5) expect(config).to.have.property('traceEnabled', true) @@ -663,9 +663,9 @@ describe('Config', () => { { name: 'codeOriginForSpans.enabled', value: true, origin: 'env_var' }, { name: 'dogstatsd.hostname', value: 'dsd-agent', origin: 'env_var' }, { name: 'dogstatsd.port', value: '5218', origin: 'env_var' }, - { name: 'dynamicInstrumentationEnabled', value: true, origin: 'env_var' }, - { name: 'dynamicInstrumentationRedactedIdentifiers', value: ['foo', 'bar'], origin: 'env_var' }, - { name: 'dynamicInstrumentationRedactionExcludedIdentifiers', value: ['a', 'b', 'c'], origin: 'env_var' }, + { name: 'dynamicInstrumentation.enabled', value: true, origin: 'env_var' }, + { name: 'dynamicInstrumentation.redactedIdentifiers', value: ['foo', 'bar'], origin: 'env_var' }, + { name: 'dynamicInstrumentation.redactionExcludedIdentifiers', value: ['a', 'b', 'c'], origin: 'env_var' }, { name: 'env', value: 'test', origin: 'env_var' }, { name: 'experimental.enableGetRumData', value: true, origin: 'env_var' }, { name: 'experimental.exporter', value: 'log', origin: 'env_var' }, @@ -858,11 +858,13 @@ describe('Config', () => { inject: ['datadog'], extract: ['datadog'] }, + dynamicInstrumentation: { + enabled: true, + redactedIdentifiers: ['foo', 'bar'], + redactionExcludedIdentifiers: ['a', 'b', 'c'] + }, experimental: { b3: true, - dynamicInstrumentationEnabled: true, - dynamicInstrumentationRedactedIdentifiers: ['foo', 'bar'], - dynamicInstrumentationRedactionExcludedIdentifiers: ['a', 'b', 'c'], traceparent: true, runtimeId: true, exporter: 'log', @@ -907,9 +909,9 @@ describe('Config', () => { expect(config).to.have.nested.property('dogstatsd.port', '5218') expect(config).to.have.property('service', 'service') expect(config).to.have.property('version', '0.1.0') - expect(config).to.have.property('dynamicInstrumentationEnabled', true) - expect(config).to.have.deep.property('dynamicInstrumentationRedactedIdentifiers', ['foo', 'bar']) - expect(config).to.have.deep.property('dynamicInstrumentationRedactionExcludedIdentifiers', ['a', 'b', 'c']) + expect(config).to.have.nested.property('dynamicInstrumentation.enabled', true) + expect(config).to.have.nested.deep.property('dynamicInstrumentation.redactedIdentifiers', ['foo', 'bar']) + expect(config).to.have.nested.deep.property('dynamicInstrumentation.redactionExcludedIdentifiers', ['a', 'b', 'c']) expect(config).to.have.property('env', 'test') expect(config).to.have.property('sampleRate', 0.5) expect(config).to.have.property('logger', logger) @@ -987,9 +989,9 @@ describe('Config', () => { { name: 'codeOriginForSpans.enabled', value: false, origin: 'code' }, { name: 'dogstatsd.hostname', value: 'agent-dsd', origin: 'code' }, { name: 'dogstatsd.port', value: '5218', origin: 'code' }, - { name: 'dynamicInstrumentationEnabled', value: true, origin: 'code' }, - { name: 'dynamicInstrumentationRedactedIdentifiers', value: ['foo', 'bar'], origin: 'code' }, - { name: 'dynamicInstrumentationRedactionExcludedIdentifiers', value: ['a', 'b', 'c'], origin: 'code' }, + { name: 'dynamicInstrumentation.enabled', value: true, origin: 'code' }, + { name: 'dynamicInstrumentation.redactedIdentifiers', value: ['foo', 'bar'], origin: 'code' }, + { name: 'dynamicInstrumentation.redactionExcludedIdentifiers', value: ['a', 'b', 'c'], origin: 'code' }, { name: 'env', value: 'test', origin: 'code' }, { name: 'experimental.enableGetRumData', value: true, origin: 'code' }, { name: 'experimental.exporter', value: 'log', origin: 'code' }, @@ -1268,11 +1270,13 @@ describe('Config', () => { inject: [], extract: [] }, + dynamicInstrumentation: { + enabled: false, + redactedIdentifiers: ['foo2', 'bar2'], + redactionExcludedIdentifiers: ['a2', 'b2'] + }, experimental: { b3: false, - dynamicInstrumentationEnabled: false, - dynamicInstrumentationRedactedIdentifiers: ['foo2', 'bar2'], - dynamicInstrumentationRedactionExcludedIdentifiers: ['a2', 'b2'], traceparent: false, runtimeId: false, exporter: 'agent', @@ -1337,9 +1341,9 @@ describe('Config', () => { expect(config).to.have.property('service', 'test') expect(config).to.have.property('version', '1.0.0') expect(config).to.have.nested.property('codeOriginForSpans.enabled', false) - expect(config).to.have.property('dynamicInstrumentationEnabled', false) - expect(config).to.have.deep.property('dynamicInstrumentationRedactedIdentifiers', ['foo2', 'bar2']) - expect(config).to.have.deep.property('dynamicInstrumentationRedactionExcludedIdentifiers', ['a2', 'b2']) + expect(config).to.have.nested.property('dynamicInstrumentation.enabled', false) + expect(config).to.have.nested.deep.property('dynamicInstrumentation.redactedIdentifiers', ['foo2', 'bar2']) + expect(config).to.have.nested.deep.property('dynamicInstrumentation.redactionExcludedIdentifiers', ['a2', 'b2']) expect(config).to.have.property('env', 'development') expect(config).to.have.property('clientIpEnabled', true) expect(config).to.have.property('clientIpHeader', 'x-true-client-ip') diff --git a/packages/dd-trace/test/debugger/devtools_client/snapshot/utils.js b/packages/dd-trace/test/debugger/devtools_client/snapshot/utils.js index 22f7610205f..fb7ebeaa10f 100644 --- a/packages/dd-trace/test/debugger/devtools_client/snapshot/utils.js +++ b/packages/dd-trace/test/debugger/devtools_client/snapshot/utils.js @@ -12,8 +12,10 @@ proxyquire('../src/debugger/devtools_client/snapshot/collector', { }) proxyquire('../src/debugger/devtools_client/snapshot/redaction', { '../config': { - dynamicInstrumentationRedactedIdentifiers: [], - dynamicInstrumentationRedactionExcludedIdentifiers: [], + dynamicInstrumentation: { + redactedIdentifiers: [], + redactionExcludedIdentifiers: [] + }, '@noCallThru': true } })