diff --git a/cmd/mdatagen/metricdata.go b/cmd/mdatagen/metricdata.go index f4515136aaed..5bf77985cc95 100644 --- a/cmd/mdatagen/metricdata.go +++ b/cmd/mdatagen/metricdata.go @@ -125,7 +125,7 @@ func (d *gauge) Unmarshal(parser *confmap.Conf) error { if err := d.MetricValueType.Unmarshal(parser); err != nil { return err } - return parser.Unmarshal(d) + return parser.Unmarshal(d, confmap.WithIgnoreUnused()) } func (d gauge) Type() string { @@ -155,7 +155,7 @@ func (d *sum) Unmarshal(parser *confmap.Conf) error { if err := d.MetricValueType.Unmarshal(parser); err != nil { return err } - return parser.Unmarshal(d) + return parser.Unmarshal(d, confmap.WithIgnoreUnused()) } // TODO: Currently, this func will not be called because of https://github.com/open-telemetry/opentelemetry-collector/issues/6671. Uncomment function and diff --git a/pkg/stanza/operator/config.go b/pkg/stanza/operator/config.go index 49fc40271a49..f9934c6a06ff 100644 --- a/pkg/stanza/operator/config.go +++ b/pkg/stanza/operator/config.go @@ -107,7 +107,7 @@ func (c *Config) Unmarshal(component *confmap.Conf) error { } builder := builderFunc() - if err := component.Unmarshal(builder); err != nil { + if err := component.Unmarshal(builder, confmap.WithIgnoreUnused()); err != nil { return fmt.Errorf("unmarshal to %s: %w", typeString, err) } diff --git a/pkg/stanza/operator/helper/time.go b/pkg/stanza/operator/helper/time.go index b6a0bc787b48..f9326c73dd18 100644 --- a/pkg/stanza/operator/helper/time.go +++ b/pkg/stanza/operator/helper/time.go @@ -48,7 +48,7 @@ type TimeParser struct { // Unmarshal starting from default settings func (t *TimeParser) Unmarshal(component *confmap.Conf) error { cfg := NewTimeParser() - err := component.Unmarshal(&cfg) + err := component.Unmarshal(&cfg, confmap.WithIgnoreUnused()) if err != nil { return err } diff --git a/pkg/stanza/operator/parser/scope/config_test.go b/pkg/stanza/operator/parser/scope/config_test.go index e7509787aedb..a3bcb83cd2cc 100644 --- a/pkg/stanza/operator/parser/scope/config_test.go +++ b/pkg/stanza/operator/parser/scope/config_test.go @@ -35,10 +35,6 @@ func TestConfig(t *testing.T) { return cfg }(), }, - { - Name: "no_nested", - ExpectErr: true, - }, }, }.Run(t) } diff --git a/pkg/stanza/operator/parser/severity/config_test.go b/pkg/stanza/operator/parser/severity/config_test.go index 905092a41738..18fa853a485d 100644 --- a/pkg/stanza/operator/parser/severity/config_test.go +++ b/pkg/stanza/operator/parser/severity/config_test.go @@ -46,10 +46,6 @@ func TestUnmarshal(t *testing.T) { return cfg }(), }, - { - Name: "no_nested", - ExpectErr: true, - }, }, }.Run(t) } diff --git a/pkg/stanza/operator/parser/time/config_test.go b/pkg/stanza/operator/parser/time/config_test.go index 1b1b5ec7e2b5..c40c2596f319 100644 --- a/pkg/stanza/operator/parser/time/config_test.go +++ b/pkg/stanza/operator/parser/time/config_test.go @@ -49,10 +49,6 @@ func TestUnmarshal(t *testing.T) { return cfg }(), }, - { - Name: "no_nested", - ExpectErr: true, - }, }, }.Run(t) }