-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Should ConfigValidator be in confmap? #11524
Comments
Is it correct to say from a component developer perspective it doesn't matter where it lives? |
Yes, but if we want to use confmap in other places like I said in |
I agree |
I don't have a strong opinion on this (which makes me lean slightly into "leave it as it is") |
Today I believe that |
Thinking about this again, I feel like it makes sense to move this to |
@bogdandrutu If we were to move this, what would we do with |
Do we even need |
@dmitryax Here are the places where this is used: https://github.com/search?q=org%3Aopen-telemetry+language%3AGo+component.ValidateConfig&type=code There are a lot of usages that could be avoided/converted, but I am not confident that we would be able to remove all of them. |
We discussed this issue during the stability SIG meeting of 1/6 and came up with the following suggestions:
|
I'll submit a PR to move validation stuff to |
@bogdandrutu @atoulme @dmitryax would adding support for https://github.com/go-playground/validator be a breaking change? Config validation is an important part of collector 1.0 and the Validator interface is a sufficient solution. I think we could move forward with our Validator interface for 1.0 and add support for https://github.com/go-playground/validator as a feature add after. |
Thinking about If we must move
Component also defines the public // Config defines the configuration for the various elements of collector or agent.
type Config struct {
// Receivers is a map of ComponentID to Receivers.
Receivers map[component.ID]component.Config `mapstructure:"receivers"`
// Exporters is a map of ComponentID to Exporters.
Exporters map[component.ID]component.Config `mapstructure:"exporters"`
// Processors is a map of ComponentID to Processors.
Processors map[component.ID]component.Config `mapstructure:"processors"`
// Connectors is a map of ComponentID to connectors.
Connectors map[component.ID]component.Config `mapstructure:"connectors"`
// Extensions is a map of ComponentID to extensions.
Extensions map[component.ID]component.Config `mapstructure:"extensions"`
Service service.Config `mapstructure:"service"`
} I agree that if Here is what I propose we do to move forward without any experimental packages.
This plan leaves |
I think we can build a shim with a ConfigValidator impl that calls out to Validator as part of a POC to see what the end user experience is. |
#12027 is open for the validator POC. |
I ran into an issue today while implementing validation in the Unmarshal. While it does work for invoking the This is because |
There is also an issues when components implement custom Unmarshal functions. For example, the otlpreceiver implements a custom unmarshaller than requires that the user have set receivers:
otlp: the collector should fail validation. The custom unmarshaller first calls |
I was able to work around the custom unmarshal issue by updating the cases in the reflective This means the components validate function may get executed multiple times. I believe that is safe. |
Created #12031 to add |
Is your feature request related to a problem? Please describe.
Currently the
ConfigValidator
is part of thecomponent
package, and for example inmdatagen
where we use confmap it is a bit strange to depend on thecomponent.ConfigValidator
for config validation.Describe the solution you'd like
Provide the configuration
Validator
as part of theconfmap
repository, and probably make it part ofConf.Unmarshal
(configurable) to also do validation.Describe alternatives you've considered
Leave where it is right now.
The text was updated successfully, but these errors were encountered: