1
1
'use strict'
2
2
3
3
const { channel } = require ( 'dc-polyfill' )
4
- const { isFalse, normalizePluginEnvName } = require ( './util' )
4
+ const { isFalse, isTrue , normalizePluginEnvName } = require ( './util' )
5
5
const plugins = require ( './plugins' )
6
6
const log = require ( './log' )
7
7
const { getEnvironmentVariable } = require ( '../../dd-trace/src/config-helper' )
@@ -32,8 +32,7 @@ loadChannel.subscribe(({ name }) => {
32
32
function maybeEnable ( Plugin ) {
33
33
if ( ! Plugin || typeof Plugin !== 'function' ) return
34
34
if ( ! pluginClasses [ Plugin . id ] ) {
35
- const envName = `DD_TRACE_${ Plugin . id . toUpperCase ( ) } _ENABLED`
36
- const enabled = getEnvironmentVariable ( normalizePluginEnvName ( envName ) )
35
+ const enabled = getEnvEnabled ( Plugin )
37
36
38
37
// TODO: remove the need to load the plugin class in order to disable the plugin
39
38
if ( isFalse ( enabled ) || disabledPlugins . has ( Plugin . id ) ) {
@@ -46,6 +45,11 @@ function maybeEnable (Plugin) {
46
45
}
47
46
}
48
47
48
+ function getEnvEnabled ( Plugin ) {
49
+ const envName = `DD_TRACE_${ Plugin . id . toUpperCase ( ) } _ENABLED`
50
+ return getEnvironmentVariable ( normalizePluginEnvName ( envName ) )
51
+ }
52
+
49
53
// TODO this must always be a singleton.
50
54
module . exports = class PluginManager {
51
55
constructor ( tracer ) {
@@ -74,7 +78,7 @@ module.exports = class PluginManager {
74
78
this . _pluginsByName [ name ] = new Plugin ( this . _tracer , this . _tracerConfig )
75
79
}
76
80
const pluginConfig = this . _configsByName [ name ] || {
77
- enabled : this . _tracerConfig . plugins !== false && ! Plugin . experimental
81
+ enabled : isTrue ( getEnvEnabled ( Plugin ) ) || ( this . _tracerConfig . plugins !== false && ! Plugin . experimental )
78
82
}
79
83
80
84
// extracts predetermined configuration from tracer and combines it with plugin-specific config
0 commit comments