-
Notifications
You must be signed in to change notification settings - Fork 487
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
Dynamic integration registration system #278
Conversation
pkg/integrations/register.go
Outdated
// Prometheus: | ||
// | ||
// https://github.com/prometheus/prometheus/blob/511511324adfc4f4178f064cc104c2deac3335de/discovery/registry.go#L111 | ||
func unmarshalIntegrationsWithList(integrations []IntegrationConfig, out interface{}, unmarshal func(interface{}) error) error { |
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.
This function makes me sad but there's really no other way to handle this. We need strict unmarshaling to still work, so we have to do what prometheus does: create a merged struct of the target + all of the possible integration fields, copy defaults to the merged struct, unmarshal to the merged struct, copy original fields back to the output, and then fill in the integrations slice.
I'll try to document this more because my original look at Prometheus' code had me really confused about what was going on and why.
@@ -1,23 +0,0 @@ | |||
package build |
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.
A go mod vendor
got rid of this.
This commit adds a dynamic integration registration system similar to (and mostly copied from) Prometheus' SD registration mechanism.
1. Integration interface moved to integrations 2. Integration Config interface now responsible for providing name/config
a72c83f
to
69fcba5
Compare
This needs a test for marshaling; pretty sure that doesn't work with this yet. |
I haven't looked at the PR in detail, but I really like this approach 👍 that manager is getting bloated with all the integration inits. |
Ready for review again! Implemented the marshaling. |
* add dynamic integration registration system This commit adds a dynamic integration registration system similar to (and mostly copied from) Prometheus' SD registration mechanism. * fix lint error * fix runtime errors * refactor integrations 1. Integration interface moved to integrations 2. Integration Config interface now responsible for providing name/config * marshal manager config with embedded integrations
PR Description
This PR adds a dynamic integration registration system similar to (and mostly copied from) Prometheus' SD registration mechanism.
Which issue(s) this PR fixes
Notes to the Reviewer
Packages have been re-arranged since integrations can now depend on the base integrations package without a cyclic dependency.
PR Checklist