-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[otelcol] Obtain the Collector's effective configuration from otelcol.Config
#10139
base: main
Are you sure you want to change the base?
[otelcol] Obtain the Collector's effective configuration from otelcol.Config
#10139
Conversation
To demonstrate the issue I'm seeing, this will fail: cfg, _ := col.configProvider.Get(ctx, factories)
conf := confmap.New()
_ = conf.Marshal(cfg)
// This fails
bytes, err := yaml.Marshal(conf.ToStringMap()) This will succeed: cfg, _ := col.configProvider.Get(ctx, factories)
// This succeeds
bytes, err := yaml.Marshal(cfg) I'm fine just letting |
I think you should look into fixing marshal. /cc @atoulme |
Thanks for the tip, I think that's also the best path forward. I found that the issue is that we don't do anything with |
943f428
to
84bf8b6
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10139 +/- ##
==========================================
- Coverage 91.90% 91.89% -0.01%
==========================================
Files 361 361
Lines 16970 16962 -8
==========================================
- Hits 15596 15588 -8
Misses 1032 1032
Partials 342 342 ☔ View full report in Codecov by Sentry. |
I have a possible solution in #10282. Basically it adds a hook which looks for structs that have |
Description
The current
ConfmapProvider
interface accurately reports the config provided to the Collector by the user, but fails to effectively report the Collector's effective configuration. In particular, it misses:Unmarshal
orValidate
methods.configopaque.String
, where we want these values to always be redacted when sent out of the Collector.As a result, I think we should attempt to get the Collector's effective configuration from
otelcol.Config
instead of using the map compiled by the confmap.Resolver. I initially intended to generate aconfmap.Conf
fromotelcol.Config
and callyaml.Marshal
on that, but this encounters errors such as being unable to marshal Prometheus config which has invalid zero values. These errors don't occur when callingyaml.Marshal
onotelcol.Config
directly. I've updated and tested updating theConfigWatcher
interface to just accept an opaqueany
-typed data object and marshal that, and the end-to-end flow works. I haven't dug into this far enough to fully understand the differences between unmarshaling each type.Two related PRs: