Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/collector/test/test_util/ProcessControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ class ProcessControls {
APP_CWD: this.cwd,
INSTANA_AGENT_PORT: agentPort,
INSTANA_LOG_LEVEL: 'warn',
INSTANA_TRACING_DISABLE: !this.tracingEnabled,
Comment thread
aryamohanan marked this conversation as resolved.
INSTANA_FORCE_TRANSMISSION_STARTING_AT: '1',
INSTANA_FULL_METRICS_INTERNAL_IN_S: 1,
INSTANA_FIRE_MONITORING_EVENT_DURATION_IN_MS: 500,
Expand All @@ -164,6 +163,13 @@ class ProcessControls {
opts.env
);

// Only set INSTANA_TRACING_DISABLE when tracing is actually disabled to avoid
// overriding other disable environment variables (INSTANA_TRACING_DISABLE_INSTRUMENTATIONS, etc.)
// See packages/core/src/config/configNormalizers/disable.js for precedence rules
if (!this.tracingEnabled) {
this.env.INSTANA_TRACING_DISABLE = 'true';
}

if (this.usePreInit) {
this.env.INSTANA_EARLY_INSTRUMENTATION = 'true';
}
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/config/configNormalizers/disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ exports.normalize = function normalize(config) {

if (envDisableConfig !== null) {
if (envDisableConfig === true) {
logger?.debug('[config] env:INSTANA_TRACING_DISABLE = true');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already logged this, removed duplicate logging

return true;
}

if (envDisableConfig === false) {
logger?.debug('[config] env:INSTANA_TRACING_DISABLE = false (overrides in-code config)');
return {};
}

Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,15 @@ function normalizeTracingConfig({ userConfig = {}, defaultConfig = {}, finalConf
* @param {{ userConfig?: InstanaConfig|null, defaultConfig?: InstanaConfig, finalConfig?: InstanaConfig }} [options]
*/
function normalizeTracingEnabled({ userConfig = {}, defaultConfig = {}, finalConfig = {} } = {}) {
// INSTANA_TRACING_DISABLE can be either:
// 1. A boolean ('true'/'false') to enable/disable all tracing
// 2. A list of instrumentations/groups to selectively disable
// We only use it for tracing.enabled if it's a boolean value
const envValue = process.env.INSTANA_TRACING_DISABLE;
const isBooleanValue = envValue === 'true' || envValue === 'false';

finalConfig.tracing.enabled = util.resolveBooleanConfigWithInvertedEnv({
envVar: 'INSTANA_TRACING_DISABLE',
envVar: isBooleanValue ? 'INSTANA_TRACING_DISABLE' : undefined,
configValue: userConfig.tracing.enabled,
defaultValue: defaultConfig.tracing.enabled,
configPath: 'config.tracing.enabled'
Expand Down