-
Notifications
You must be signed in to change notification settings - Fork 373
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
Integration configuration settings #450
Conversation
887e679
to
afe57f3
Compare
@delner quick question before proceeding with the review. The previous Configuration API works exactly as before so no changes are required in users code, right? |
@palazzem Yup, its completely backwards compatible with users applications. They should not require any updates to their configurations in order to be compatible. |
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.
Two small comments.
Other than that it looks really good!
lib/ddtrace/configuration.rb
Outdated
if integration.class <= Datadog::Contrib::Integration | ||
integration.configuration(configuration_name) | ||
else | ||
Proxy.new(integration) |
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.
caching of the proxy object would need to be ported back.
But it looks to me like integration.configuration(cfg_name)
already avoids temporary object creation 👍
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.
Ahhh, yes, good point. Would save some memory.
module ClassMethods | ||
def register_as(name, options = {}) | ||
registry = options.fetch(:registry, Datadog.registry) | ||
auto_patch = options.fetch(:auto_patch, false) |
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.
Autopatch seems to not be used anymore. Is this only for backwards compatibility ? If so I think we can just not support it in the new configuration approach anymore.
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.
Backwards compatibility, yeah. I'm not sure whether we can remove this, since there are a lot of users who upgrade from really old versions (< 0.10.0
) and leave auto_patch
in their configuration. Let me look deeper into this, but this is a great point for consideration.
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.
@pawelchcki @delner no breaking changes must be introduced that way. If there is a risk to break something at bootstrap time, we need to add a deprecation warning and decide when we're going to remove that field. Probably we can remove most of the things once we're heading to 1.0 release.
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.
@palazzem agreed.
However this shouldn't affect integrations that do not explicitly include new Registerable
module. Also the user still would be able to call the same method signature register_as :name, auto_patch: true
. Now auto_patch
will be ignored a bit earlier.
It doesn't look like breaking change to me.
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.
afe57f3
to
c412d1c
Compare
Just looking over this, I realized this needs more test coverage for the new components. I will implement some basic specs, then resubmit this for review. |
@pawelchcki @palazzem Added more test coverage; this should be good for another review. |
Thanks! @delner looks good! |
In order to encourage more flexible configuration design in our integrations, this pull request introduces a common core for integration configuration settings. This allows us to improve on several things:
Allow the use of block syntax:
Introduce configuration multiplexing
Some integrations must trace multiple endpoints through the same code path, and require additional configuration for each endpoint to do so. Multiplexing allows you to define an arbitrary key that can be associated to specific trace settings, then recalled when needed.
Support for composite configurations
Some integrations activate additional integrations in order to perform tracing. However, those additional integrations are not configurable via the parent integration, and require users to configure them separately.
By implementing object-based configuration with custom methods, it's possible to passthrough configuration settings to underlying integrations without coupling the parent integration to the configuration details of the additional integration.
Rails is a good example of this, which activates
rack
andactive_record
by default.Additional remarks
By implementing this configuration core, we also gain additional benefits of DRYing up configuration code, and reducing coupling. These changes are backwards compatible, and can be implemented on an integration-to-integration basis, which would grant us flexibility in their implementation.
See examples of integrations that implement this configuration core here:
active_record
: Implement ActiveRecord integration configuration #451sequel
: Implement Sequel integration configuration #452