diff --git a/packages/core/src/config/configNormalizers/disable.js b/packages/core/src/config/configNormalizers/disable.js index 2cebaac499..a94da1e252 100644 --- a/packages/core/src/config/configNormalizers/disable.js +++ b/packages/core/src/config/configNormalizers/disable.js @@ -19,33 +19,56 @@ exports.init = function init(_config) { * Handles environment variables, and array inputs. * * Precedence order (highest to lowest): - * 1. `tracing.disable` - * 2. Environment variables (`INSTANA_TRACING_DISABLE*`) + * 1. Environment variables (`INSTANA_TRACING_DISABLE*`) + * 2. In-code tracing.disable * * @param {import('../../config').InstanaConfig} config */ exports.normalize = function normalize(config) { if (!config?.tracing) config.tracing = {}; try { - // Disable all tracing if explicitly set 'disable' to true + const envDisableConfig = getDisableFromEnv(); + + if (envDisableConfig !== null) { + if (envDisableConfig === true) { + logger?.debug('[config] env:INSTANA_TRACING_DISABLE = true'); + return true; + } + + if (envDisableConfig === false) { + logger?.debug('[config] env:INSTANA_TRACING_DISABLE = false (overrides in-code config)'); + return {}; + } + + if (envDisableConfig.instrumentations?.length || envDisableConfig.groups?.length) { + logger?.debug(`[config] env:INSTANA_TRACING_DISABLE* = ${JSON.stringify(envDisableConfig)}`); + + if (envDisableConfig.instrumentations) { + envDisableConfig.instrumentations = normalizeArray(envDisableConfig.instrumentations); + } + if (envDisableConfig.groups) { + envDisableConfig.groups = normalizeArray(envDisableConfig.groups); + } + + return envDisableConfig; + } + } + if (config.tracing.disable === true) { logger?.debug('[config] incode:tracing.disable = true'); - return true; } + const hasDisableConfig = isDisableConfigNonEmpty(config); if (hasDisableConfig) { logger?.debug(`[config] incode:tracing.disable = ${JSON.stringify(config.tracing.disable)}`); } - // Fallback to environment variables if `disable` is not explicitly configured - const disableConfig = isDisableConfigNonEmpty(config) ? config.tracing.disable : getDisableFromEnv(); + const disableConfig = isDisableConfigNonEmpty(config) ? config.tracing.disable : null; if (!disableConfig) return {}; - if (disableConfig === true) return true; - // Normalize instrumentations and groups if (disableConfig?.instrumentations) { disableConfig.instrumentations = normalizeArray(disableConfig.instrumentations); @@ -90,7 +113,7 @@ exports.normalizeExternalConfig = function normalizeExternalConfig(config) { * 2. INSTANA_TRACING_DISABLE_INSTRUMENTATIONS / INSTANA_TRACING_DISABLE_GROUPS * 3. INSTANA_TRACING_DISABLE=list * - * @returns {import('../../config/types').Disable} + * @returns {import('../../config/types').Disable | boolean | null} */ function getDisableFromEnv() { const disable = {}; @@ -104,7 +127,12 @@ function getDisableFromEnv() { return true; } - if (envVarValue !== 'false' && envVarValue !== '') { + if (envVarValue === 'false') { + logger?.debug('[config] env:INSTANA_TRACING_DISABLE = false'); + return false; + } + + if (envVarValue !== '') { const categorized = categorizeDisableEntries(parseEnvVar(envVarValue)); if (categorized?.instrumentations?.length) { disable.instrumentations = categorized.instrumentations; diff --git a/packages/core/src/config/configNormalizers/stackTrace.js b/packages/core/src/config/configNormalizers/stackTrace.js index 2a0bb89ef2..9b0a596b04 100644 --- a/packages/core/src/config/configNormalizers/stackTrace.js +++ b/packages/core/src/config/configNormalizers/stackTrace.js @@ -25,7 +25,7 @@ exports.normalizeStackTraceMode = function (config) { /** * Normalizes stack trace length configuration based on precedence. - * Precedence: global config > config > env var > default + * Precedence: env var > global config > config > default * @param {import('../../config').InstanaConfig} config * @returns {number} - Normalized value */ diff --git a/packages/core/src/config/index.js b/packages/core/src/config/index.js index c313fdab69..efe66e2e5b 100644 --- a/packages/core/src/config/index.js +++ b/packages/core/src/config/index.js @@ -190,6 +190,12 @@ module.exports.normalize = ({ userConfig = {}, finalConfigBase = {}, defaultsOve function normalizeServiceName(userConfig, defaultConfig, finalConfig) { const userValue = userConfig.serviceName; + if (process.env.INSTANA_SERVICE_NAME) { + finalConfig.serviceName = process.env.INSTANA_SERVICE_NAME; + logger.debug(`[config] env:INSTANA_SERVICE_NAME = ${process.env.INSTANA_SERVICE_NAME}`); + return; + } + if (userValue != null) { if (typeof userValue === 'string') { finalConfig.serviceName = userValue; @@ -198,12 +204,10 @@ function normalizeServiceName(userConfig, defaultConfig, finalConfig) { logger.warn(`Invalid configuration: config.serviceName is not a string, the value will be ignored: ${userValue}`); finalConfig.serviceName = defaultConfig.serviceName; } - } else if (process.env.INSTANA_SERVICE_NAME) { - finalConfig.serviceName = process.env.INSTANA_SERVICE_NAME; - logger.debug(`[config] env:INSTANA_SERVICE_NAME = ${process.env.INSTANA_SERVICE_NAME}`); - } else { - finalConfig.serviceName = defaultConfig.serviceName; + return; } + + finalConfig.serviceName = defaultConfig.serviceName; } /** @@ -214,6 +218,14 @@ function normalizeServiceName(userConfig, defaultConfig, finalConfig) { function normalizePackageJsonPath(userConfig, defaultConfig, finalConfig) { const userValue = userConfig.packageJsonPath; + // Priority 1: Environment variable + if (process.env.INSTANA_PACKAGE_JSON_PATH) { + finalConfig.packageJsonPath = process.env.INSTANA_PACKAGE_JSON_PATH; + logger.debug(`[config] env:INSTANA_PACKAGE_JSON_PATH = ${process.env.INSTANA_PACKAGE_JSON_PATH}`); + return; + } + + // Priority 2: In-code configuration if (userValue != null) { if (typeof userValue === 'string') { finalConfig.packageJsonPath = userValue; @@ -224,12 +236,11 @@ function normalizePackageJsonPath(userConfig, defaultConfig, finalConfig) { ); finalConfig.packageJsonPath = defaultConfig.packageJsonPath; } - } else if (process.env.INSTANA_PACKAGE_JSON_PATH) { - finalConfig.packageJsonPath = process.env.INSTANA_PACKAGE_JSON_PATH; - logger.debug(`[config] env:INSTANA_PACKAGE_JSON_PATH = ${process.env.INSTANA_PACKAGE_JSON_PATH}`); - } else { - finalConfig.packageJsonPath = defaultConfig.packageJsonPath; + return; } + + // Priority 3: Default value + finalConfig.packageJsonPath = defaultConfig.packageJsonPath; } /** @@ -404,36 +415,31 @@ function normalizeTracingHttp(userConfig, defaultConfig, finalConfig) { const userHttp = userConfig.tracing.http; finalConfig.tracing.http = {}; - let fromEnvVar; if (process.env.INSTANA_EXTRA_HTTP_HEADERS) { - fromEnvVar = parseHeadersEnvVar(process.env.INSTANA_EXTRA_HTTP_HEADERS); - } - - const userHeaders = userHttp?.extraHttpHeadersToCapture; - - if (!userHeaders && !fromEnvVar) { - finalConfig.tracing.http.extraHttpHeadersToCapture = defaultConfig.tracing.http.extraHttpHeadersToCapture; - return; - } else if (!userHeaders && fromEnvVar) { + const fromEnvVar = parseHeadersEnvVar(process.env.INSTANA_EXTRA_HTTP_HEADERS); finalConfig.tracing.http.extraHttpHeadersToCapture = fromEnvVar; logger.debug(`[config] env:INSTANA_EXTRA_HTTP_HEADERS = ${process.env.INSTANA_EXTRA_HTTP_HEADERS}`); return; - } else if (finalConfig.tracing.http.extraHttpHeadersToCapture) { - logger.debug('[config] incode:config.tracing.http.extraHttpHeadersToCapture'); } - if (!Array.isArray(userHeaders)) { - logger.warn( - // eslint-disable-next-line max-len - `Invalid configuration: config.tracing.http.extraHttpHeadersToCapture is not an array, the value will be ignored: ${JSON.stringify( - userHeaders - )}` - ); - finalConfig.tracing.http.extraHttpHeadersToCapture = defaultConfig.tracing.http.extraHttpHeadersToCapture; + const userHeaders = userHttp?.extraHttpHeadersToCapture; + if (userHeaders != null) { + if (!Array.isArray(userHeaders)) { + logger.warn( + // eslint-disable-next-line max-len + `Invalid configuration: config.tracing.http.extraHttpHeadersToCapture is not an array, the value will be ignored: ${JSON.stringify( + userHeaders + )}` + ); + finalConfig.tracing.http.extraHttpHeadersToCapture = defaultConfig.tracing.http.extraHttpHeadersToCapture; + return; + } + finalConfig.tracing.http.extraHttpHeadersToCapture = userHeaders.map(s => s.toLowerCase()); + logger.debug('[config] incode:config.tracing.http.extraHttpHeadersToCapture'); return; } - finalConfig.tracing.http.extraHttpHeadersToCapture = userHeaders.map(s => s.toLowerCase()); + finalConfig.tracing.http.extraHttpHeadersToCapture = defaultConfig.tracing.http.extraHttpHeadersToCapture; } /** @@ -748,14 +754,7 @@ function normalizeIgnoreEndpoints(userConfig, defaultConfig, finalConfig) { return; } - // Case 1: Use in-code configuration if available - if (userIgnoreEndpoints && Object.keys(userIgnoreEndpoints).length) { - finalConfig.tracing.ignoreEndpoints = configNormalizers.ignoreEndpoints.normalizeConfig(userIgnoreEndpoints); - logger.debug('[config] incode:config.tracing.ignoreEndpoints'); - return; - } - - // Case 2: Load from a YAML file if `INSTANA_IGNORE_ENDPOINTS_PATH` is set + // Priority 1: Load from a YAML file if `INSTANA_IGNORE_ENDPOINTS_PATH` is set // Introduced in Phase 2 for advanced filtering based on both methods and endpoints. // Also supports basic filtering for endpoints. if (process.env.INSTANA_IGNORE_ENDPOINTS_PATH) { @@ -766,7 +765,7 @@ function normalizeIgnoreEndpoints(userConfig, defaultConfig, finalConfig) { return; } - // Case 3: Load from the `INSTANA_IGNORE_ENDPOINTS` environment variable + // Priority 2: Load from the `INSTANA_IGNORE_ENDPOINTS` environment variable // Introduced in Phase 1 for basic filtering based only on operations (e.g., `redis.get`, `kafka.consume`). // Provides a simple way to configure ignored operations via environment variables. if (process.env.INSTANA_IGNORE_ENDPOINTS) { @@ -777,6 +776,13 @@ function normalizeIgnoreEndpoints(userConfig, defaultConfig, finalConfig) { return; } + // Priority 3: Use in-code configuration if available + if (userIgnoreEndpoints && Object.keys(userIgnoreEndpoints).length) { + finalConfig.tracing.ignoreEndpoints = configNormalizers.ignoreEndpoints.normalizeConfig(userIgnoreEndpoints); + logger.debug('[config] incode:config.tracing.ignoreEndpoints'); + return; + } + finalConfig.tracing.ignoreEndpoints = defaultConfig.tracing.ignoreEndpoints; } diff --git a/packages/core/src/config/util.js b/packages/core/src/config/util.js index 836ae8803b..68d4ab2b0e 100644 --- a/packages/core/src/config/util.js +++ b/packages/core/src/config/util.js @@ -85,6 +85,20 @@ function parseBooleanFromEnv(envValue) { * @returns {boolean} */ exports.resolveBooleanConfig = function resolveBooleanConfig({ envVar, configValue, defaultValue, configPath }) { + // Priority 1: Environment variable + const envValue = process.env[envVar]; + const envParsed = parseBooleanFromEnv(envValue); + + if (envParsed !== undefined) { + logger.debug(`[config] env:${envVar} = ${envParsed}`); + return envParsed; + } + + if (envValue != null) { + logger.warn(`Invalid boolean value for ${envVar}: "${envValue}". Checking in-code config.`); + } + + // Priority 2: In-code configuration if (typeof configValue === 'boolean') { logger.debug(`[config] incode:${configPath} = ${configValue}`); return configValue; @@ -98,18 +112,7 @@ exports.resolveBooleanConfig = function resolveBooleanConfig({ envVar, configVal ); } - const envValue = process.env[envVar]; - const envParsed = parseBooleanFromEnv(envValue); - - if (envParsed !== undefined) { - logger.debug(`[config] env:${envVar} = ${envParsed}`); - return envParsed; - } - - if (envValue != null) { - logger.warn(`Invalid boolean value for ${envValue}: "${envValue}".`); - } - + // Priority 3: Default value return defaultValue; }; @@ -130,16 +133,24 @@ exports.resolveBooleanConfigWithInvertedEnv = function resolveBooleanConfigWithI defaultValue, configPath }) { - if (typeof configValue === 'boolean') { - logger.debug(`[config] incode:${configPath} = ${configValue}`); + // Priority 1: Environment variable + const envValue = process.env[envVar]; + const envParsed = parseBooleanFromEnv(envValue); - return configValue; + if (envParsed !== undefined) { + const invertedValue = !envParsed; + logger.debug(`[config] env:${envVar} = ${envParsed} (inverted to ${invertedValue})`); + return invertedValue; } - const envValue = process.env[envVar]; - if (envValue === 'true') { - logger.debug(`[config] env:${envVar} = true (inverted to false)`); - return false; + if (envValue != null) { + logger.warn(`Invalid boolean value for ${envVar}: "${envValue}". Checking in-code config.`); + } + + // Priority 2: In-code configuration + if (typeof configValue === 'boolean') { + logger.debug(`[config] incode:${configPath} = ${configValue}`); + return configValue; } if (configValue != null && configPath) { @@ -150,6 +161,7 @@ exports.resolveBooleanConfigWithInvertedEnv = function resolveBooleanConfigWithI ); } + // Priority 3: Default value return defaultValue; }; @@ -170,16 +182,19 @@ exports.resolveBooleanConfigWithTruthyEnv = function resolveBooleanConfigWithTru defaultValue, configPath }) { - if (typeof configValue === 'boolean') { - logger.debug(`[config] incode:${configPath} = ${configValue}`); - return configValue; - } - + // Priority 1: Environment variable (truthy check) const envValue = process.env[envVar]; if (envValue) { logger.debug(`[config] env:${envVar} = ${envValue}`); return true; } + // Priority 2: In-code configuration + if (typeof configValue === 'boolean') { + logger.debug(`[config] incode:${configPath} = ${configValue}`); + return configValue; + } + + // Priority 3: Default value return defaultValue; }; diff --git a/packages/core/test/config/configNormalizers/disable_test.js b/packages/core/test/config/configNormalizers/disable_test.js index b24817dccf..d3b98a7e2d 100644 --- a/packages/core/test/config/configNormalizers/disable_test.js +++ b/packages/core/test/config/configNormalizers/disable_test.js @@ -288,7 +288,7 @@ describe('util.configNormalizers.disable', () => { expect(result).to.deep.equal({}); }); - it.skip('should give precedence to INSTANA_TRACING_DISABLE=false over config.tracing.disable=true', () => { + it('should give precedence to INSTANA_TRACING_DISABLE=false over config.tracing.disable=true', () => { process.env.INSTANA_TRACING_DISABLE = 'false'; const config = { @@ -301,7 +301,7 @@ describe('util.configNormalizers.disable', () => { expect(result).to.deep.equal({}); }); - it.skip('should give precedence to INSTANA_TRACING_DISABLE=false over config with instrumentations', () => { + it('should give precedence to INSTANA_TRACING_DISABLE=false over config with instrumentations', () => { process.env.INSTANA_TRACING_DISABLE = 'false'; const config = { diff --git a/packages/core/test/config/normalizeConfig_test.js b/packages/core/test/config/normalizeConfig_test.js index 1c07d112ab..29cce22a13 100644 --- a/packages/core/test/config/normalizeConfig_test.js +++ b/packages/core/test/config/normalizeConfig_test.js @@ -73,12 +73,12 @@ describe('config.normalizeConfig', () => { expect(config.serviceName).to.not.exist; }); - it.skip('should use config when env not set', () => { + it('should use config when env not set', () => { const config = coreConfig.normalize({ userConfig: { serviceName: 'config-service-name' } }); expect(config.serviceName).to.equal('config-service-name'); }); - it.skip('should give precedence to INSTANA_SERVICE_NAME env var over config', () => { + it('should give precedence to INSTANA_SERVICE_NAME env var over config', () => { process.env.INSTANA_SERVICE_NAME = 'env-service'; const config = coreConfig.normalize({ userConfig: { serviceName: 'config-service' } }); expect(config.serviceName).to.equal('env-service'); @@ -114,7 +114,7 @@ describe('config.normalizeConfig', () => { expect(config.metrics.transmissionDelay).to.equal(1000); }); - it.skip('should give precedence to INSTANA_METRICS_TRANSMISSION_DELAY env var over config', () => { + it('should give precedence to INSTANA_METRICS_TRANSMISSION_DELAY env var over config', () => { process.env.INSTANA_METRICS_TRANSMISSION_DELAY = '3000'; const config = coreConfig.normalize({ userConfig: { metrics: { transmissionDelay: 5000 } } }); expect(config.metrics.transmissionDelay).to.equal(3000); @@ -188,19 +188,19 @@ describe('config.normalizeConfig', () => { expect(config.tracing.enabled).to.be.true; }); - it.skip('should give precedence to INSTANA_TRACING_DISABLE env var set to true over config set to true', () => { + it('should give precedence to INSTANA_TRACING_DISABLE env var set to true over config set to true', () => { process.env.INSTANA_TRACING_DISABLE = 'true'; const config = coreConfig.normalize({ userConfig: { tracing: { enabled: true } } }); expect(config.tracing.enabled).to.be.false; }); - it.skip('should give precedence to INSTANA_TRACING_DISABLE env var set to false over config set to false', () => { + it('should give precedence to INSTANA_TRACING_DISABLE env var set to false over config set to false', () => { process.env.INSTANA_TRACING_DISABLE = 'false'; const config = coreConfig.normalize({ userConfig: { tracing: { enabled: false } } }); expect(config.tracing.enabled).to.be.true; }); - it.skip('should give precedence to INSTANA_TRACING_DISABLE env var over default', () => { + it('should give precedence to INSTANA_TRACING_DISABLE env var over default', () => { process.env.INSTANA_TRACING_DISABLE = 'true'; const config = coreConfig.normalize({}); expect(config.tracing.enabled).to.be.false; @@ -211,19 +211,19 @@ describe('config.normalizeConfig', () => { expect(config.tracing.automaticTracingEnabled).to.be.true; }); - it.skip('should give precedence to INSTANA_DISABLE_AUTO_INSTR env var set to true over config set to true', () => { + it('should give precedence to INSTANA_DISABLE_AUTO_INSTR env var set to true over config set to true', () => { process.env.INSTANA_DISABLE_AUTO_INSTR = 'true'; const config = coreConfig.normalize({ userConfig: { tracing: { automaticTracingEnabled: true } } }); expect(config.tracing.automaticTracingEnabled).to.be.false; }); - it.skip('should give precedence to INSTANA_DISABLE_AUTO_INSTR env var set to false over config set to false', () => { + it('should give precedence to INSTANA_DISABLE_AUTO_INSTR env var set to false over config set to false', () => { process.env.INSTANA_DISABLE_AUTO_INSTR = 'false'; const config = coreConfig.normalize({ userConfig: { tracing: { automaticTracingEnabled: false } } }); expect(config.tracing.automaticTracingEnabled).to.be.true; }); - it.skip('should give precedence to INSTANA_DISABLE_AUTO_INSTR env var over default', () => { + it('should give precedence to INSTANA_DISABLE_AUTO_INSTR env var over default', () => { process.env.INSTANA_DISABLE_AUTO_INSTR = 'true'; const config = coreConfig.normalize({}); expect(config.tracing.automaticTracingEnabled).to.be.false; @@ -260,13 +260,13 @@ describe('config.normalizeConfig', () => { expect(config.tracing.activateImmediately).to.be.false; }); - it.skip('should give precedence to INSTANA_TRACE_IMMEDIATELY env var set to true over config set to false', () => { + it('should give precedence to INSTANA_TRACE_IMMEDIATELY env var set to true over config set to false', () => { process.env.INSTANA_TRACE_IMMEDIATELY = 'true'; const config = coreConfig.normalize({ userConfig: { tracing: { activateImmediately: false } } }); expect(config.tracing.activateImmediately).to.be.true; }); - it.skip('should give precedence to INSTANA_TRACE_IMMEDIATELY env var set to false over config set to true', () => { + it('should give precedence to INSTANA_TRACE_IMMEDIATELY env var set to false over config set to true', () => { process.env.INSTANA_TRACE_IMMEDIATELY = 'false'; const config = coreConfig.normalize({ userConfig: { tracing: { activateImmediately: true } } }); expect(config.tracing.activateImmediately).to.be.false; @@ -305,13 +305,13 @@ describe('config.normalizeConfig', () => { expect(config.tracing.transmissionDelay).to.equal(1000); }); - it.skip('should give precedence to INSTANA_TRACING_TRANSMISSION_DELAY env var over config', () => { + it('should give precedence to INSTANA_TRACING_TRANSMISSION_DELAY env var over config', () => { process.env.INSTANA_TRACING_TRANSMISSION_DELAY = '4000'; const config = coreConfig.normalize({ userConfig: { tracing: { transmissionDelay: 2000 } } }); expect(config.tracing.transmissionDelay).to.equal(4000); }); - it.skip('should give precedence to INSTANA_FORCE_TRANSMISSION_STARTING_AT env var over config', () => { + it('should give precedence to INSTANA_FORCE_TRANSMISSION_STARTING_AT env var over config', () => { process.env.INSTANA_FORCE_TRANSMISSION_STARTING_AT = '700'; const config = coreConfig.normalize({ userConfig: { tracing: { forceTransmissionStartingAt: 300 } } }); expect(config.tracing.forceTransmissionStartingAt).to.equal(700); @@ -413,7 +413,7 @@ describe('config.normalizeConfig', () => { expect(config.tracing.stackTraceLength).to.equal(3); }); - it.skip('should give precedence to INSTANA_STACK_TRACE_LENGTH over config', () => { + it('should give precedence to INSTANA_STACK_TRACE_LENGTH over config', () => { process.env.INSTANA_STACK_TRACE_LENGTH = '5'; const normalizedConfig = coreConfig.normalize({ userConfig: { tracing: { stackTraceLength: 20 } } }); expect(normalizedConfig.tracing.stackTraceLength).to.equal(5); @@ -452,7 +452,7 @@ describe('config.normalizeConfig', () => { expect(config.tracing.stackTrace).to.equal('none'); }); - it.skip('should give precedence to env INSTANA_STACK_TRACE over config', () => { + it('should give precedence to env INSTANA_STACK_TRACE over config', () => { process.env.INSTANA_STACK_TRACE = 'none'; const config = coreConfig.normalize({ userConfig: { tracing: { global: { stackTrace: 'all' } } } }); expect(config.tracing.stackTrace).to.equal('none'); @@ -699,7 +699,7 @@ describe('config.normalizeConfig', () => { expect(config.tracing.stackTraceLength).to.equal(30); }); - it.skip('should give precedence to env vars for both stack trace settings over config', () => { + it('should give precedence to env vars for both stack trace settings over config', () => { process.env.INSTANA_STACK_TRACE = 'error'; process.env.INSTANA_STACK_TRACE_LENGTH = '15'; const config = coreConfig.normalize({ @@ -751,7 +751,7 @@ describe('config.normalizeConfig', () => { expect(config.tracing.disable.instrumentations).to.deep.equal(['graphql', 'grpc']); }); - it('config should take precedence over INSTANA_TRACING_DISABLE_INSTRUMENTATIONS for config', () => { + it('env var INSTANA_TRACING_DISABLE_INSTRUMENTATIONS over config', () => { process.env.INSTANA_TRACING_DISABLE_INSTRUMENTATIONS = 'foo, bar'; const config = coreConfig.normalize({ userConfig: { @@ -760,7 +760,7 @@ describe('config.normalizeConfig', () => { } } }); - expect(config.tracing.disable.instrumentations).to.deep.equal(['baz', 'fizz']); + expect(config.tracing.disable.instrumentations).to.deep.equal(['foo', 'bar']); }); it('should disable multiple instrumentations via env var INSTANA_TRACING_DISABLE_INSTRUMENTATIONS', () => { @@ -798,7 +798,7 @@ describe('config.normalizeConfig', () => { expect(config.tracing.disable.groups).to.deep.equal(['frameworks', 'databases']); }); - it('config should take precedence over INSTANA_TRACING_DISABLE_GROUPS when disabling groups', () => { + it('env var should take precedence over config when disabling groups', () => { process.env.INSTANA_TRACING_DISABLE_GROUPS = 'frameworks, databases'; const config = coreConfig.normalize({ userConfig: { @@ -807,7 +807,7 @@ describe('config.normalizeConfig', () => { } } }); - expect(config.tracing.disable.groups).to.deep.equal(['logging']); + expect(config.tracing.disable.groups).to.deep.equal(['frameworks', 'databases']); }); it('should disable instrumentations and groups when both configured', () => { @@ -890,13 +890,13 @@ describe('config.normalizeConfig', () => { expect(config.tracing.spanBatchingEnabled).to.be.false; }); - it.skip('should give precedence to INSTANA_SPANBATCHING_ENABLED env var set to true over config set to false', () => { + it('should give precedence to INSTANA_SPANBATCHING_ENABLED env var set to true over config set to false', () => { process.env.INSTANA_SPANBATCHING_ENABLED = 'true'; const config = coreConfig.normalize({ userConfig: { tracing: { spanBatchingEnabled: false } } }); expect(config.tracing.spanBatchingEnabled).to.be.true; }); - it.skip('should give precedence to INSTANA_SPANBATCHING_ENABLED env var set to false over config set to true', () => { + it('should give precedence to INSTANA_SPANBATCHING_ENABLED env var set to false over config set to true', () => { process.env.INSTANA_SPANBATCHING_ENABLED = 'false'; const config = coreConfig.normalize({ userConfig: { tracing: { spanBatchingEnabled: true } } }); expect(config.tracing.spanBatchingEnabled).to.be.false; @@ -920,7 +920,7 @@ describe('config.normalizeConfig', () => { expect(config.tracing.disableW3cTraceCorrelation).to.be.false; }); - it.skip('should give precedence to INSTANA_DISABLE_W3C_TRACE_CORRELATION env var over config (truthy env)', () => { + it('should give precedence to INSTANA_DISABLE_W3C_TRACE_CORRELATION env var over config (truthy env)', () => { process.env.INSTANA_DISABLE_W3C_TRACE_CORRELATION = 'any-value'; const config = coreConfig.normalize({ userConfig: { tracing: { disableW3cTraceCorrelation: false } } }); expect(config.tracing.disableW3cTraceCorrelation).to.be.true; @@ -944,13 +944,13 @@ describe('config.normalizeConfig', () => { expect(config.tracing.kafka.traceCorrelation).to.be.true; }); - it.skip('should give precedence to INSTANA_KAFKA_TRACE_CORRELATION env var set to false over config set to true', () => { + it('should give precedence to INSTANA_KAFKA_TRACE_CORRELATION env var set to false over config set to true', () => { process.env.INSTANA_KAFKA_TRACE_CORRELATION = 'false'; const config = coreConfig.normalize({ userConfig: { tracing: { kafka: { traceCorrelation: true } } } }); expect(config.tracing.kafka.traceCorrelation).to.be.false; }); - it.skip('should give precedence to INSTANA_KAFKA_TRACE_CORRELATION env var set to true over config set to false', () => { + it('should give precedence to INSTANA_KAFKA_TRACE_CORRELATION env var set to true over config set to false', () => { process.env.INSTANA_KAFKA_TRACE_CORRELATION = 'true'; const config = coreConfig.normalize({ userConfig: { tracing: { kafka: { traceCorrelation: false } } } }); expect(config.tracing.kafka.traceCorrelation).to.be.true; @@ -993,13 +993,13 @@ describe('config.normalizeConfig', () => { expect(config.tracing.useOpentelemetry).to.be.true; }); - it.skip('should give precedence to INSTANA_DISABLE_USE_OPENTELEMETRY env var set to true over config set to true', () => { + it('should give precedence to INSTANA_DISABLE_USE_OPENTELEMETRY env var set to true over config set to true', () => { process.env.INSTANA_DISABLE_USE_OPENTELEMETRY = 'true'; const config = coreConfig.normalize({ userConfig: { tracing: { useOpentelemetry: true } } }); expect(config.tracing.useOpentelemetry).to.be.false; }); - it.skip('should give precedence to INSTANA_DISABLE_USE_OPENTELEMETRY env var set to false over config set to false', () => { + it('should give precedence to INSTANA_DISABLE_USE_OPENTELEMETRY env var set to false over config set to false', () => { process.env.INSTANA_DISABLE_USE_OPENTELEMETRY = 'false'; const config = coreConfig.normalize({ userConfig: { tracing: { useOpentelemetry: false } } }); expect(config.tracing.useOpentelemetry).to.be.true; @@ -1096,12 +1096,12 @@ describe('config.normalizeConfig', () => { expect(config.packageJsonPath).to.equal('/my/path'); }); - it.skip('should use default (null) when neither env nor config is set', () => { + it('should use default (null) when neither env nor config is set', () => { const config = coreConfig.normalize({}); expect(config.packageJsonPath).to.be.null; }); - it.skip('should give precedence to INSTANA_PACKAGE_JSON_PATH env var over config', () => { + it('should give precedence to INSTANA_PACKAGE_JSON_PATH env var over config', () => { process.env.INSTANA_PACKAGE_JSON_PATH = '/env/path/package.json'; const config = coreConfig.normalize({ userConfig: { packageJsonPath: '/config/path/package.json' } }); expect(config.packageJsonPath).to.equal('/env/path/package.json'); @@ -1143,13 +1143,13 @@ describe('config.normalizeConfig', () => { expect(config.tracing.allowRootExitSpan).to.be.false; }); - it.skip('should give precedence to INSTANA_ALLOW_ROOT_EXIT_SPAN env var set to true over config set to false', () => { + it('should give precedence to INSTANA_ALLOW_ROOT_EXIT_SPAN env var set to true over config set to false', () => { process.env.INSTANA_ALLOW_ROOT_EXIT_SPAN = 'true'; const config = coreConfig.normalize({ userConfig: { tracing: { allowRootExitSpan: false } } }); expect(config.tracing.allowRootExitSpan).to.be.true; }); - it.skip('should give precedence to INSTANA_ALLOW_ROOT_EXIT_SPAN env var set to false over config set to true', () => { + it('should give precedence to INSTANA_ALLOW_ROOT_EXIT_SPAN env var set to false over config set to true', () => { process.env.INSTANA_ALLOW_ROOT_EXIT_SPAN = 'false'; const config = coreConfig.normalize({ userConfig: { tracing: { allowRootExitSpan: true } } }); expect(config.tracing.allowRootExitSpan).to.be.false; @@ -1348,13 +1348,13 @@ describe('config.normalizeConfig', () => { expect(config.tracing.ignoreEndpointsDisableSuppression).to.be.false; }); - it.skip('should give precedence to INSTANA_IGNORE_ENDPOINTS_DISABLE_SUPPRESSION env var set to true over config set to false', () => { + it('should give precedence to INSTANA_IGNORE_ENDPOINTS_DISABLE_SUPPRESSION env var set to true over config set to false', () => { process.env.INSTANA_IGNORE_ENDPOINTS_DISABLE_SUPPRESSION = 'true'; const config = coreConfig.normalize({ userConfig: { tracing: { ignoreEndpointsDisableSuppression: false } } }); expect(config.tracing.ignoreEndpointsDisableSuppression).to.be.true; }); - it.skip('should give precedence to INSTANA_IGNORE_ENDPOINTS_DISABLE_SUPPRESSION env var set to false over config set to true', () => { + it('should give precedence to INSTANA_IGNORE_ENDPOINTS_DISABLE_SUPPRESSION env var set to false over config set to true', () => { process.env.INSTANA_IGNORE_ENDPOINTS_DISABLE_SUPPRESSION = 'false'; const config = coreConfig.normalize({ userConfig: { tracing: { ignoreEndpointsDisableSuppression: true } } }); expect(config.tracing.ignoreEndpointsDisableSuppression).to.be.false; @@ -1462,13 +1462,13 @@ describe('config.normalizeConfig', () => { expect(config.tracing.disableEOLEvents).to.be.true; }); - it.skip('should give precedence to INSTANA_TRACING_DISABLE_EOL_EVENTS env var set to true over config set to false', () => { + it('should give precedence to INSTANA_TRACING_DISABLE_EOL_EVENTS env var set to true over config set to false', () => { process.env.INSTANA_TRACING_DISABLE_EOL_EVENTS = 'true'; const config = coreConfig.normalize({ userConfig: { tracing: { disableEOLEvents: false } } }); expect(config.tracing.disableEOLEvents).to.be.true; }); - it.skip('should give precedence to INSTANA_TRACING_DISABLE_EOL_EVENTS env var set to false over config set to true', () => { + it('should give precedence to INSTANA_TRACING_DISABLE_EOL_EVENTS env var set to false over config set to true', () => { process.env.INSTANA_TRACING_DISABLE_EOL_EVENTS = 'false'; const config = coreConfig.normalize({ userConfig: { tracing: { disableEOLEvents: true } } }); expect(config.tracing.disableEOLEvents).to.be.false;