-
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
[confmap] Should not marshal functions/channels by default #8627
Comments
My vote is on moving the |
I would still rather have the marshaler skip the fields. Ran into this issue with another configuration in the contrib (https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/operator/input/tcp/tcp.go#L79) and, while that should be fixed as well, doing it in the marshaler will prevent these changes from breaking the functionality. |
@djaglowski any thoughts on this? Does |
I don't believe it's a common pattern, at least not to have them exported. In this case, I don't see any reason why the we couldn't just unexport the field. |
It had to be exported because that was the only way to set it. However, it's unused in any non-test code inside upstream components, so I agree we can essentially hide it. Considering it can easily be set on the client returned from |
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Deprecates the `CustomRoundTripper` field on `confighttp.ClientConfig`, which is unused outside tests in Contrib and causes errors because it cannot be unmarshaled or marshaled. Additionally, having a non-configurable field on a Config struct seems non-ideal. Soft depends on open-telemetry/opentelemetry-collector-contrib#33371 so we're not using deprecated APIs. <!-- Issue number if applicable --> #### Link to tracking issue Fixes #8627 <!--Describe what testing was performed and which tests were added.--> #### Testing Adapted tests to how the new way of doing this will look. It's slightly less ergonomic (you can't load up all the settings then just run `ToClient`), but we have no examples of this being used by any components, so I'm reluctant to add it to the API.
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Delete deprecated `ClientConfig.CustomRoundTripper` <!-- Issue number if applicable --> #### Link to tracking issue Fixes #8627
@evan-bradley looks like ToClient returns a copy of the client, so we can't actually set a custom transport to be used by a component. Am I missing something? |
Describe the bug
mapstructure
will take any exported field and attempt to decode it. This includes non-tagged fields.https://pkg.go.dev/github.com/mitchellh/mapstructure
Similarly, the
mapstructure
encoder will also take any exported field and attempt to encode it into a form thatgo-yaml
can use. The encoder does not handle function or channel types. Any exported function/channel which will use the default handler, which will fall back on leaving the field as is.go-yaml
cannot handle the function/channel and panics.One example of an exported function in the configuration is the
confighttp.HTTPClientSettings
, which exports the CustomRoundTripper function:opentelemetry-collector/config/confighttp/confighttp.go
Lines 52 to 53 in b5635a7
Steps to reproduce
What did you expect to see?
That the function would be skipped.
customroundtripper
is not present in the output YAML.What did you see instead?
What version did you use?
Version: v0.86.0
What config did you use?
Config: N/A
Environment
OS: (e.g., "Ubuntu 20.04") macOS
Compiler(if manually compiled): Go 1.20.8
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: