Skip to content
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

Merged
merged 5 commits into from
Jan 5, 2021

Conversation

rfratto
Copy link
Member

@rfratto rfratto commented Dec 8, 2020

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

  • CHANGELOG updated (internal change, not needed)
  • Documentation added (internal change, not needed)
  • Tests updated

// Prometheus:
//
// https://github.com/prometheus/prometheus/blob/511511324adfc4f4178f064cc104c2deac3335de/discovery/registry.go#L111
func unmarshalIntegrationsWithList(integrations []IntegrationConfig, out interface{}, unmarshal func(interface{}) error) error {
Copy link
Member Author

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
Copy link
Member Author

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
@rfratto rfratto marked this pull request as ready for review December 11, 2020 17:19
@rfratto rfratto requested a review from a team December 11, 2020 17:20
@rfratto
Copy link
Member Author

rfratto commented Dec 14, 2020

This needs a test for marshaling; pretty sure that doesn't work with this yet.

@rfratto rfratto marked this pull request as draft December 14, 2020 20:24
@dafydd-t
Copy link
Contributor

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.

@rfratto rfratto marked this pull request as ready for review December 15, 2020 22:08
@rfratto
Copy link
Member Author

rfratto commented Dec 15, 2020

Ready for review again! Implemented the marshaling.

@rfratto rfratto merged commit 9e37baf into grafana:master Jan 5, 2021
@rfratto rfratto deleted the dynamic-integrations branch January 5, 2021 19:21
@mattdurham mattdurham mentioned this pull request Sep 7, 2021
3 tasks
mattdurham pushed a commit that referenced this pull request Nov 11, 2021
* 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
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Apr 22, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants