Skip to content

Commit 712addc

Browse files
committed
remove old implementation
1 parent 58565ee commit 712addc

File tree

2 files changed

+6
-65
lines changed

2 files changed

+6
-65
lines changed

packages/datadog-instrumentations/src/helpers/register.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const log = require('../../../dd-trace/src/log')
99
const checkRequireCache = require('./check-require-cache')
1010
const telemetry = require('../../../dd-trace/src/guardrails/telemetry')
1111
const { isInServerlessEnvironment } = require('../../../dd-trace/src/serverless')
12-
const { isFalse, isTrue, normalizePluginEnvName } = require('../../../dd-trace/src/util')
12+
const { isFalse } = require('../../../dd-trace/src/util')
1313
const { getEnvironmentVariables } = require('../../../dd-trace/src/config-helper')
1414

1515
const envs = getEnvironmentVariables()
@@ -25,20 +25,15 @@ const names = Object.keys(hooks)
2525
const pathSepExpr = new RegExp(`\\${path.sep}`, 'g')
2626

2727
const disabledInstrumentations = new Set(
28-
DD_TRACE_DISABLED_INSTRUMENTATIONS?.split(',').map(name => normalizePluginEnvName(name, true)) ?? []
28+
DD_TRACE_DISABLED_INSTRUMENTATIONS?.split(',') ?? []
2929
)
30-
const reenabledInstrumentations = new Set()
3130

3231
// Check for DD_TRACE_<INTEGRATION>_ENABLED environment variables
3332
for (const [key, value] of Object.entries(envs)) {
3433
const match = key.match(/^DD_TRACE_(.+)_ENABLED$/)
35-
if (match && value) {
36-
const integration = normalizePluginEnvName(match[1], true)
37-
if (isFalse(value)) {
38-
disabledInstrumentations.add(integration)
39-
} else if (isTrue(value)) {
40-
reenabledInstrumentations.add(integration)
41-
}
34+
if (match && isFalse(value)) {
35+
const integration = match[1].toLowerCase()
36+
disabledInstrumentations.add(integration)
4237
}
4338
}
4439

@@ -65,8 +60,7 @@ const allInstrumentations = {}
6560

6661
// TODO: make this more efficient
6762
for (const packageName of names) {
68-
const normalizedPackageName = normalizePluginEnvName(packageName, true)
69-
if (disabledInstrumentations.has(normalizedPackageName)) continue
63+
if (disabledInstrumentations.has(packageName)) continue
7064

7165
const hookOptions = {}
7266

@@ -75,10 +69,6 @@ for (const packageName of names) {
7569
if (hook !== null && typeof hook === 'object') {
7670
if (hook.serverless === false && isInServerlessEnvironment()) continue
7771

78-
// some integrations are disabled by default, but can be enabled by setting
79-
// the DD_TRACE_<INTEGRATION>_ENABLED environment variable to true
80-
if (hook.disabled && !reenabledInstrumentations.has(normalizedPackageName)) continue
81-
8272
hookOptions.internals = hook.esmFirst
8373
hook = hook.fn
8474
}

packages/datadog-instrumentations/test/helpers/register.spec.js

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ describe('register', () => {
2020

2121
hooksMock = {
2222
'@confluentinc/kafka-javascript': {
23-
disabled: true,
2423
fn: sinon.stub().returns('hooked')
2524
},
2625
'mongodb-core': {
@@ -72,54 +71,6 @@ describe('register', () => {
7271
}
7372
}
7473

75-
it('should skip hooks that are disabled by default and process enabled hooks', () => {
76-
loadRegisterWithEnv()
77-
78-
expect(HookMock.callCount).to.equal(1)
79-
expect(HookMock.args[0]).to.deep.include(['mongodb-core'], { internals: undefined })
80-
81-
runHookCallbacks(HookMock)
82-
83-
expect(hooksMock['@confluentinc/kafka-javascript'].fn).to.not.have.been.called
84-
expect(hooksMock['mongodb-core'].fn).to.have.been.called
85-
})
86-
87-
it('should enable disabled hooks when DD_TRACE_[pkg]_ENABLED is true', () => {
88-
loadRegisterWithEnv({ DD_TRACE_CONFLUENTINC_KAFKA_JAVASCRIPT_ENABLED: 'true' })
89-
90-
expect(HookMock.callCount).to.equal(2)
91-
expect(HookMock.args[0]).to.deep.include(['@confluentinc/kafka-javascript'], { internals: undefined })
92-
expect(HookMock.args[1]).to.deep.include(['mongodb-core'], { internals: undefined })
93-
94-
runHookCallbacks(HookMock)
95-
96-
expect(hooksMock['@confluentinc/kafka-javascript'].fn).to.have.been.called
97-
expect(hooksMock['mongodb-core'].fn).to.have.been.called
98-
})
99-
100-
it('should not enable disabled hooks when DD_TRACE_[pkg]_ENABLED is false', () => {
101-
loadRegisterWithEnv({ DD_TRACE_CONFLUENTINC_KAFKA_JAVASCRIPT_ENABLED: 'false' })
102-
103-
expect(HookMock.callCount).to.equal(1)
104-
expect(HookMock.args[0]).to.deep.include(['mongodb-core'], { internals: undefined })
105-
106-
runHookCallbacks(HookMock)
107-
108-
expect(hooksMock['@confluentinc/kafka-javascript'].fn).to.not.have.been.called
109-
expect(hooksMock['mongodb-core'].fn).to.have.been.called
110-
})
111-
112-
it('should disable hooks that are disabled by DD_TRACE_[pkg]_ENABLED=false', () => {
113-
loadRegisterWithEnv({ DD_TRACE_MONGODB_CORE_ENABLED: 'false' })
114-
115-
expect(HookMock.callCount).to.equal(0)
116-
117-
runHookCallbacks(HookMock)
118-
119-
expect(hooksMock['@confluentinc/kafka-javascript'].fn).to.not.have.been.called
120-
expect(hooksMock['mongodb-core'].fn).to.not.have.been.called
121-
})
122-
12374
it('should disable hooks that are disabled by DD_TRACE_DISABLED_INSTRUMENTATIONS', () => {
12475
loadRegisterWithEnv({ DD_TRACE_DISABLED_INSTRUMENTATIONS: 'mongodb-core,@confluentinc/kafka-javascript' })
12576

0 commit comments

Comments
 (0)