refactor: build config from user config instead of mutating pre-filled object#2448
Draft
aryamohanan wants to merge 2 commits intofix-config-precedencefrom
Draft
refactor: build config from user config instead of mutating pre-filled object#2448aryamohanan wants to merge 2 commits intofix-config-precedencefrom
aryamohanan wants to merge 2 commits intofix-config-precedencefrom
Conversation
aryamohanan
commented
Mar 30, 2026
aryamohanan
commented
Mar 30, 2026
19 tasks
a22667e to
77ab6ce
Compare
kirrg001
reviewed
Mar 31, 2026
Comment on lines
+247
to
+275
| function normalizeTracingConfig(userConfig, defaultConfig, finalConfig) { | ||
| finalConfig.tracing = {}; | ||
|
|
||
| normalizeTracingEnabled(userConfig, defaultConfig, finalConfig); | ||
| normalizeUseOpentelemetry(userConfig, defaultConfig, finalConfig); | ||
| normalizeDisableTracing(userConfig, defaultConfig, finalConfig); | ||
| normalizeAutomaticTracingEnabled(userConfig, defaultConfig, finalConfig); | ||
| normalizeActivateImmediately(userConfig, defaultConfig, finalConfig); | ||
| normalizeTracingTransmission(userConfig, defaultConfig, finalConfig); | ||
| normalizeTracingHttp(userConfig, defaultConfig, finalConfig); | ||
| normalizeTracingStackTrace(userConfig, defaultConfig, finalConfig); | ||
| normalizeSpanBatchingEnabled(userConfig, defaultConfig, finalConfig); | ||
| normalizeDisableW3cTraceCorrelation(userConfig, defaultConfig, finalConfig); | ||
| normalizeTracingKafka(userConfig, defaultConfig, finalConfig); | ||
| normalizeAllowRootExitSpan(userConfig, defaultConfig, finalConfig); | ||
| normalizeIgnoreEndpoints(userConfig, defaultConfig, finalConfig); | ||
| normalizeIgnoreEndpointsDisableSuppression(userConfig, defaultConfig, finalConfig); | ||
| normalizeDisableEOLEvents(userConfig, defaultConfig, finalConfig); | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @param {InstanaConfig} config | ||
| * @param {InstanaConfig|null} userConfig | ||
| * @param {InstanaConfig} defaultConfig | ||
| * @param {InstanaConfig} finalConfig | ||
| */ | ||
| function normalizeTracingEnabled(config) { | ||
| config.tracing.enabled = util.resolveBooleanConfigWithInvertedEnv({ | ||
| function normalizeTracingEnabled(userConfig, defaultConfig, finalConfig) { | ||
| finalConfig.tracing.enabled = util.resolveBooleanConfigWithInvertedEnv({ | ||
| envVar: 'INSTANA_TRACING_DISABLE', | ||
| configValue: config.tracing.enabled, | ||
| defaultValue: defaults.tracing.enabled, | ||
| configValue: userConfig?.tracing?.enabled, |
Contributor
There was a problem hiding this comment.
Do we really need these extra optional chainings? I see them a lot in this PR
Contributor
Author
There was a problem hiding this comment.
Optional chaining ensures safe access when userConfig is null or undefined, or when the tracing property is missing, thereby preventing runtime errors. I believe it will be particularly useful when dealing with user-provided configuration input.
Contributor
There was a problem hiding this comment.
Ya but we overuse it.
userConfig?.tracing?
There is IMO not reason to always to optional chaining for ^
We do it 17 times.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Normalization functions previously operated on a pre-filled config, making it unclear whether values were resolved or already present. This change separates input and output, making value resolution explicit and easier to reason about.