-
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
[otelcol] Obtain the Collector's effective configuration from otelcol.Config
#10139
[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 92.35% 92.26% -0.09%
==========================================
Files 395 395
Lines 18706 18703 -3
==========================================
- Hits 17275 17257 -18
- Misses 1070 1086 +16
+ Partials 361 360 -1 ☔ 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:** <Describe what has changed.> Redacts primitive values in the effective config reported by the extension. Necessary for #31641 until open-telemetry/opentelemetry-collector#10139 is resolved. Relates to #32983
Possible solution for #10139 (comment) More thorough explanation here: #10139 (comment) --------- Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
It seems like the ask to:
is now supported following: Are there any other scenarios where the code snippet above will fail ? |
@mackjmr You're right, this will work now; thanks for keeping an eye on it. I haven't been able to get back to this, but I have more time now and will push an update this week. |
0f70ae9
to
aee771d
Compare
aee771d
to
9694609
Compare
conf := confmap.New() | ||
|
||
if err = conf.Marshal(cfg); err != nil { | ||
return fmt.Errorf("could not marshal configuration: %w", err) |
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.
Another option could be to make this only a warning log, if we're comfortable that all extensions asking for the effective configuration will get an empty map.
@@ -142,12 +144,3 @@ func (cm *configProvider) Watch() <-chan error { | |||
func (cm *configProvider) Shutdown(ctx context.Context) error { | |||
return cm.mapResolver.Shutdown(ctx) | |||
} | |||
|
|||
func (cm *configProvider) GetConfmap(ctx context.Context) (*confmap.Conf, error) { |
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.
Should we keep a dummy implementation of this method for one or more releases that returns an error saying that this functionality is deprecated?
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 removed this because I don't expect anyone else is using it, but thinking on it, this should go through the normal deprecation process. I've added a deprecation notice to this method and we can just remove the implementation when we remove the interface. I would feel comfortable removing both one release after deprecating them.
is this purely internal change, or can the end user print the config now? |
This only affects the Collector APIs, but it is a step towards allowing the user to print the config. |
**Description:** Now that open-telemetry/opentelemetry-collector#10139 is merged, we can rely on the Collector APIs to redact sensitive fields in the config for us. I tested this against the latest Collector core commit with the goal that this will land in the v0.105.0 release.
Description
The
otelcol.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.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. This also allows us to get rid ofotelcol.ConfmapProvider
.I have manually tested this using an OpAMP Supervisor setup, but wasn't able to add unit tests due to the way
otelcol.Collector
is written.