[otelcol] Fix missing defaults in unredacted print-config - #14752
Conversation
Merging this PR will not alter performance
|
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (92.59%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #14752 +/- ##
==========================================
- Coverage 91.24% 91.23% -0.02%
==========================================
Files 697 697
Lines 44647 44658 +11
==========================================
+ Hits 40738 40742 +4
- Misses 2769 2774 +5
- Partials 1140 1142 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @axw, the slight coverage drop is just the basic The core |
jmacd
left a comment
There was a problem hiding this comment.
Days with a recursive function in them++. Thanks.
| // the whole component config is not defaulted. | ||
| "unredacted": `other: lala`, | ||
| "redacted": `opaque: '[REDACTED]'`, | ||
| "unredacted": `opaque: '[REDACTED]'`, |
There was a problem hiding this comment.
is this value not expected to be unredacted as well?
There was a problem hiding this comment.
Since default values aren't in the user's raw input, we don't have a cleartext source to restore them from. So it stays as [REDACTED].
There was a problem hiding this comment.
I'm unresolving this as I think there may be another option. We can choose not to go with it, but we should still discuss whether this is acceptable.
There was a problem hiding this comment.
I'm not very familiar with this part of the code base, so I asked Claude Code to take a look. It came up with a different approach which will also work for default values (#14752 (comment)).
The approach is basically to introduce a new confmap.MarshalOption that disables redaction during marshaling. I think that seems like a simpler and more foolproof solution. What do you think?
The code it generated is at https://github.com/axw/opentelemetry-collector/tree/fix/14750-unredacted-defaults. I wouldn't necessarily use it as-is, just sharing for reference.
|
I haven't looked deeply into this, but I agree that the current approach (relying on the |
…nation URL in error messages Signed-off-by: EdgeN8v <ckx19921555595@gmail.com>
Fixes open-telemetry#14750 Signed-off-by: EdgeN8v <ckx19921555595@gmail.com>
Signed-off-by: EdgeN8v <ckx19921555595@gmail.com>
Signed-off-by: EdgeN8v <ckx19921555595@gmail.com>
Signed-off-by: EdgeN8v <ckx19921555595@gmail.com>
Signed-off-by: EdgeN8v <ckx19921555595@gmail.com>
Signed-off-by: EdgeN8v <ckx19921555595@gmail.com>
Signed-off-by: EdgeN8v <ckx19921555595@gmail.com>
f38d40a to
e84b6e6
Compare
| if _, ok := from.Interface().(encoding.TextMarshaler); ok { | ||
| return from.String(), nil | ||
| } |
There was a problem hiding this comment.
This feels like quite a subtle tight coupling to configopaque.Opaque. Instead, perhaps we should introduce an interface like
type UnredactedStringer interface {
UnredactedString() string
}and have configopaque.Opaque implement it.
|
I would rather avoid adding public API to a stable module like |
dmathieu
left a comment
There was a problem hiding this comment.
The move to xconfmap is quite nice.
| if _, ok := from.Interface().(encoding.TextMarshaler); ok { | ||
| return from.String(), nil | ||
| } |
Co-authored-by: Vihas Makwana <121151420+VihasMakwana@users.noreply.github.com>
Pull Request is not mergeable
f594326
…etry#14752) **Description** Fixes an issue where `otelcol print-config --mode=unredacted` omits default values, causing its output structure to differ significantly from `redacted` mode. *Implementation details:* This PR introduces a new `confmap.WithUnredacted()` `MarshalOption` and an `unredactedStringer` interface within the `mapstructure` encoder. This allows the configuration to be marshaled natively without redaction, preserving all default values while cleanly decoupling the encoder from `configopaque`. The previous recursive post-processing workaround has been entirely removed. **Link to tracking issue** Fixes open-telemetry#14750 **Testing** * Removed obsolete tests related to the recursive workaround. * Updated `TestPrintCommand` in `command_print_test.go` to assert default values are correctly handled natively in `unredacted` mode. * Passed `make test` locally. **Documentation** * Added `.chloggen` entry. --------- Signed-off-by: EdgeN8v <ckx19921555595@gmail.com> Co-authored-by: Damien Mathieu <42@dmathieu.com> Co-authored-by: Vihas Makwana <121151420+VihasMakwana@users.noreply.github.com> Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
Description
Fixes an issue where
otelcol print-config --mode=unredactedomits default values, causing its output structure to differ significantly fromredactedmode.Implementation details:
This PR introduces a new
confmap.WithUnredacted()MarshalOptionand anunredactedStringerinterface within themapstructureencoder. This allows the configuration to be marshaled natively without redaction, preserving all default values while cleanly decoupling the encoder fromconfigopaque. The previous recursive post-processing workaround has been entirely removed.Link to tracking issue
Fixes #14750
Testing
TestPrintCommandincommand_print_test.goto assert default values are correctly handled natively inunredactedmode.make testlocally.Documentation
.chloggenentry.