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
2 changes: 1 addition & 1 deletion packages/collector/src/announceCycle/unannounced.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function applyDisableConfiguration(agentResponse) {
ensureNestedObjectExists(agentOpts.config, ['tracing', 'disable']);
agentOpts.config.tracing.disable = configNormalizers.disable.normalizeExternalConfig({
tracing: { disable: disablingConfig }
});
}).value;
}
module.exports = {
init,
Expand Down
21 changes: 11 additions & 10 deletions packages/core/src/config/configNormalizers/disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'use strict';

const { DISABLABLE_INSTRUMENTATION_GROUPS } = require('../../tracing/constants');
const { CONFIG_SOURCES } = require('../../util/constants');
/** @type {import('../../core').GenericLogger} */
let logger;

Expand All @@ -31,11 +32,11 @@ exports.normalize = function normalize(config) {

if (envDisableConfig !== null) {
if (envDisableConfig === true) {
return true;
return { value: true, source: CONFIG_SOURCES.ENV };
}

if (envDisableConfig === false) {
return {};
return { value: {}, source: CONFIG_SOURCES.ENV };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this right?

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.

This is the case when INSTANA_TRACING_DISABLE=false.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤔 Why is the value {}

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 treat disable as object type internaly

Copy link
Copy Markdown
Contributor Author

@aryamohanan aryamohanan Apr 20, 2026

Choose a reason for hiding this comment

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

the external config type mixed with boolean and array obj, but internally we treat it as object.
INSTANA_TRACING_DISABLE can accept both boolean and obj array

}

if (envDisableConfig.instrumentations?.length || envDisableConfig.groups?.length) {
Expand All @@ -48,13 +49,13 @@ exports.normalize = function normalize(config) {
envDisableConfig.groups = normalizeArray(envDisableConfig.groups);
}

return envDisableConfig;
return { value: envDisableConfig, source: CONFIG_SOURCES.ENV };
}
}

if (config.tracing.disable === true) {
logger?.debug('[config] incode:tracing.disable = true');
return true;
return { value: true, source: CONFIG_SOURCES.INCODE };
}

const hasDisableConfig = isDisableConfigNonEmpty(config);
Expand All @@ -65,7 +66,7 @@ exports.normalize = function normalize(config) {

const disableConfig = isDisableConfigNonEmpty(config) ? config.tracing.disable : null;

if (!disableConfig) return {};
if (!disableConfig) return { value: {}, source: CONFIG_SOURCES.DEFAULT };

// Normalize instrumentations and groups
if (disableConfig?.instrumentations) {
Expand All @@ -77,14 +78,14 @@ exports.normalize = function normalize(config) {

// Handle if tracing.disable is an array
if (Array.isArray(disableConfig)) {
return categorizeDisableEntries(disableConfig);
return { value: categorizeDisableEntries(disableConfig), source: CONFIG_SOURCES.INCODE };
}

return disableConfig || {};
return { value: disableConfig || {}, source: CONFIG_SOURCES.INCODE };
} catch (error) {
// Fallback to an empty disable config on error
logger?.debug(`Error while normalizing tracing.disable config: ${error?.message} ${error?.stack}`);
return {};
return { value: {}, source: CONFIG_SOURCES.DEFAULT };
}
};

Expand All @@ -96,13 +97,13 @@ exports.normalizeExternalConfig = function normalizeExternalConfig(config) {
try {
if (isNonEmptyObject(config.tracing.disable)) {
const flattenedEntries = flattenDisableConfigs(config.tracing.disable);
return categorizeDisableEntries(flattenedEntries);
return { value: categorizeDisableEntries(flattenedEntries), source: CONFIG_SOURCES.AGENT };
}
} catch (error) {
logger?.debug(`Error while normalizing external tracing.disable config: ${error?.message} ${error?.stack}`);
}

return {};
return { value: {}, source: CONFIG_SOURCES.DEFAULT };
};

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ function normalizeDisableTracing({ userConfig = {}, defaultConfig = {}, finalCon
return;
}

if (typeof disableConfig === 'object' && (disableConfig.instrumentations?.length || disableConfig.groups?.length)) {
if (typeof disableConfig === 'object' && disableRes.source !== CONFIG_SOURCES.DEFAULT) {
finalConfig.tracing.disable = disableConfig;
configStore.set('config.tracing.disable', {
source: disableRes.source
Expand Down
Loading