Skip to content

Commit

Permalink
[DI] Add namespace to all DI related config options (#5077)
Browse files Browse the repository at this point in the history
This affects all DI related config options, where the `experimental`
namespace is removed and, and a `dynamicInstrumentation` namespace is
introduced.

Changes:

- `experimental.dynamicInstrumentationEnabled` -> `dynamicInstrumentation.enabled`
- `experimental.dynamicInstrumentationRedactedIdentifiers` ->
  `dynamicInstrumentation.redactedIdentifiers`
- `experimental.dynamicInstrumentationRedactionExcludedIdentifiers` ->
  `dynamicInstrumentation.redactionExcludedIdentifiers`
  • Loading branch information
watson authored Jan 9, 2025
1 parent 98e733f commit 6e5d2e8
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 45 deletions.
22 changes: 11 additions & 11 deletions packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions packages/dd-trace/src/debugger/devtools_client/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
58 changes: 31 additions & 27 deletions packages/dd-trace/test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@
"dynamicInstrumentationEnabled": "dynamic_instrumentation_enabled",
"dynamicInstrumentationRedactedIdentifiers": "dynamic_instrumentation_redacted_identifiers",
"dynamicInstrumentationRedactionExcludedIdentifiers": "dynamic_instrumentation_redaction_excluded_indentifiers",
"dynamicInstrumentation.enabled": "dynamic_instrumentation_enabled",
"dynamicInstrumentation.redactedIdentifiers": "dynamic_instrumentation_redacted_identifiers",
"dynamicInstrumentation.redactionExcludedIdentifiers": "dynamic_instrumentation_redaction_excluded_indentifiers",
"dynamic_instrumentation.enabled": "dynamic_instrumentation_enabled",
"dynamic_instrumentation.redacted_identifiers": "dynamic_instrumentation_redacted_identifiers",
"dynamic_instrumentation.redacted_types": "dynamic_instrumentation_redacted_types",
Expand Down
1 change: 1 addition & 0 deletions packages/dd-trace/test/proxy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ describe('TracerProxy', () => {
appsec: {},
iast: {},
crashtracking: {},
dynamicInstrumentation: {},
remoteConfig: {
enabled: true
},
Expand Down

0 comments on commit 6e5d2e8

Please sign in to comment.