-
Notifications
You must be signed in to change notification settings - Fork 395
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
[core] Update config to allow configuration before patching #650
[core] Update config to allow configuration before patching #650
Conversation
Previously if we tried to set a config setting before the contrib module was imported we would receive an error that the integration key did not exist. With this new approach we are allowing any integration setting to be configured by the user, whenever they want and then when we call `config._add()` in the contrib module, we will merge the settings with any existing settings, keeping those that already exist. We have also added a Config.__repr__
An explanation of the current problem is probably good too... If we tried to do: import ddtrace
ddtrace.patch_all(requests=True)
ddtrace.config.requests['split_by_domain'] = True We would receive an exception, because With these changes, the above will work, and when we |
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.
Just added a few comments for typos. Other than that looks great!
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.
Approach is fine and I prefer to keep this API. Also _add
is internal so we can revisit it after if we hit a road blocker when migrating all integrations to the Config
API.
), | ||
), | ||
)) | ||
eq_(self.config.requests['a']['b']['c'], True) |
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.
👍
c7af42a
CI is green, Github rate limited CircleCI again 🙄 |
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.
LGTM. Really liked this PR, the problem it was trying to solve appeared very clear in the comments and code is clear. ❤️
Previously if we tried to set a config setting before the contrib module was imported
we would receive an error that the integration key did not exist.
With this new approach we are allowing any integration setting to be configured by
the user, whenever they want and then when we call
config._add()
in the contribmodule, we will merge the settings with any existing settings, keeping those that
already exist.
We have also added a
Config.__repr__