New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ddtrace/tracer: fixed precedence ordering of configuration options #1232
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f88aa2c
ddtrace/tracer: fixed precedence ordering of configuration options
dianashevchenko 77eff54
removed redundant calls to resolveAgentAddr
dianashevchenko 0974809
Refactored: removed inforcing of the code path; updated tests
dianashevchenko 3978199
Merge branch 'v1' into shevchenko/config-precedence-order
dianashevchenko c6c82ed
Merge branch 'v1' into shevchenko/config-precedence-order
dianashevchenko File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably best to get rid of this completely and follow the same pattern as the other settings. We can move the env. var. checks together with the rest of the env. var checks for the other options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would have to do it after running all the in-code options, I doubt that this change would contribute to cleaner code. Also, since it's in a separate function order of precedence is clear, no need to worry about someone moving around pieces of code
dd-trace-go/ddtrace/tracer/option.go
Lines 212 to 233 in 77eff54
As for the regression test, we have up to date
TestResolveAgentAddr
, which verify correct order of in-code options, env variables, and default values.dd-trace-go/ddtrace/tracer/transport_test.go
Lines 80 to 88 in 77eff54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I didn't notice it at first, the Github diff was not too great.
It's about being consistent. Also, you are passing an empty string to a function which is not used anywhere else and technically its argument has no value. You are intentionally passing bad input to force a certain code path. I don't think that's the right approach. It's an old piece of code. Better to get rid of it and be consistent. Or am I missing something? Why do we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reckon it's better to have the logic in the separate function, because otherwise 'configuration precedence order' relies only on the position in the code, which could be changed accidentaly in the future. Instead, I'll remove the arguments to the resolveAddr func and update tests according to that