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

Add ConfigUnmarshaler interface to allow mutations on the parsed Config #3706

Merged
merged 1 commit into from
Aug 16, 2021

Conversation

bogdandrutu
Copy link
Member

Fixes #3023

Signed-off-by: Bogdan Drutu [email protected]

@bogdandrutu bogdandrutu requested review from a team and Aneurysm9 July 23, 2021 21:41
@bogdandrutu
Copy link
Member Author

bogdandrutu commented Jul 23, 2021

/cc @jcchavezs @pavolloffay

@tigrannajaryan tigrannajaryan requested a review from pjanotti July 30, 2021 02:46
@tigrannajaryan
Copy link
Member

Build failed somewhere in config tests, not sure if related to the change.

Copy link
Contributor

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I first read the name ConfigLoader I thought that it was related to load the configuration file. The "loader" unmarshall a config parser into a service configuration. Perhaps the name should be something around config builder or unmarshall, load sounds to me more about "loading" the configuration into the parser.

service/settings.go Outdated Show resolved Hide resolved
@bogdandrutu
Copy link
Member Author

@pjanotti good feedback, will update the PR.

@bogdandrutu bogdandrutu force-pushed the configloader branch 2 times, most recently from 0d63e98 to d09d696 Compare August 5, 2021 01:04
@bogdandrutu bogdandrutu changed the title Add ConfigLoader interface to allow mutations on the parsed Config Add ConfigUnmarshaler interface to allow mutations on the parsed Config Aug 5, 2021
@bogdandrutu bogdandrutu force-pushed the configloader branch 3 times, most recently from 4d26981 to 1ea3760 Compare August 5, 2021 01:08
service/collector.go Outdated Show resolved Hide resolved
service/collector.go Outdated Show resolved Hide resolved
@bogdandrutu bogdandrutu force-pushed the configloader branch 4 times, most recently from e2ad4e9 to 6f2c469 Compare August 6, 2021 17:13
@bogdandrutu
Copy link
Member Author

@tigrannajaryan @jrcamp @dmitryax can one of you approve this?

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Looking forward to see docs in a future PR.

@jcchavezs
Copy link
Contributor

jcchavezs commented Aug 11, 2021

My 2p here: I think this PR addresses #3023 in a unexpected way, if someone wants to apply some changes over config object then they need to implement the ConfigUnmarshaler interface (yet not caring about unmarshaling at all) by wrapping the default one or whatever user wants to use, this is somehow inconvenient because the interface isn't explicit and users wouldn't expect the config to change in this step and also it does not guarantee us this changes are the last processing for config which could lead us to unexpected behaviours in the future.

I wonder if there are actual use cases where ConfigUnmarshaler interface works a use case by itself and point out them in this PR.

For our use case we patched the collector with this approach (not saying this is the best but it looks very explicit: hypertrace@7c9197e).

@bogdandrutu
Copy link
Member Author

bogdandrutu commented Aug 11, 2021

@jcchavezs I think even though this may not seem as intuitive, this design choice gives us the best of both worlds. The reason is because it is generic enough to allow us to change the unmarshalling logic as well as being able to change the generated config.

I do understand your concern, but I would say that your proposal is very focused on your use-case, and may be too specific, so instead I believe that going with a more generic approach like this allows us to extend in the future everything that we need. There may be implementations that need to use other structure tags, or that may override some values, etc.

Also the chaining proposed has the same problem of ordering as you pointed if using this interface, because it is not guaranteed that the "config processors" will be configured in the expected order (similar issues).

This proposal also avoids adding new concepts like "config processors" so I think in some ways it is simpler.

@bogdandrutu bogdandrutu merged commit cce6f70 into open-telemetry:main Aug 16, 2021
@bogdandrutu bogdandrutu deleted the configloader branch August 16, 2021 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add/bring back API to programmatically change config
6 participants