Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Support set flag for component configs #1640
Support set flag for component configs #1640
Changes from all commits
2a02f47
100c39e
6033505
e67eb7e
1b11e75
eb6e633
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why do we do this? Code is not clear and looks suspect (we get and set all keys?). Add comment.
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.
I have added a comment
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.
I am not sure I like how we depend on specific components from here. Can we use
componenttest
and example components for testing instead?I would prefer to minimize the coupling between this package and actual component packages.
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.
The test was already using
"go.opentelemetry.io/collector/service/defaultcomponents"
. The components were parsed but not accessed directly. For instance this config was used by this testopentelemetry-collector/service/testdata/otelcol-config.yaml
Line 1 in 9778b16
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.
@tigrannajaryan have a look at this test.
If the flag references an unknown property the factory returns an error. However, if the flag references a valid component that is not in the config file e.g.
batch/foo
then an error is not returned (see the next test) and a new component instance is created that is not enabled in the pipeline. I think that this behaviour is fine.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 is the part that I don't like. If I have a typo in my
--set
flag and the name of the component is incorrect then it will have no effect and there will be no indication to the user that something went wrong.Preferably in this case the startup should fail and tell that the component is not found. Is it possible to do?
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.
I cannot think of a simple solution. The same can happen with the config file a user can forget to add a component to a pipeline.
The ugly solution might be to parse the config in
FileLoaderConfigFactory
then pass it intoAddSetFlagProperties
which would parse it's own config and compare which components are not in the pipeline. Then parse the final config at the end ofFileLoaderConfigFactory
with the final viper. This is a rather horrible solution :).Maybe we could print a warning for not assigned components during the config validation?
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.
Why do we build a properties file first? Can't we apply the
flagProperties
directly tov
here? If there is a reason please add comments to explain.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.
I have added a comment to the source file.