Skip to content

Commit

Permalink
[chore] fix code to support unmarshaling with embedded struct support (
Browse files Browse the repository at this point in the history
…open-telemetry#31406)

**Description:**
Code changes required to make
open-telemetry/opentelemetry-collector#9635
pass.
  • Loading branch information
atoulme authored and XinRanZhAWS committed Mar 13, 2024
1 parent fc947b0 commit f1b3f0c
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/mdatagen/metricdata.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/config.go
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/operator/helper/time.go
Expand Up @@ -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
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/stanza/operator/parser/scope/config_test.go
Expand Up @@ -35,10 +35,6 @@ func TestConfig(t *testing.T) {
return cfg
}(),
},
{
Name: "no_nested",
ExpectErr: true,
},
},
}.Run(t)
}
4 changes: 0 additions & 4 deletions pkg/stanza/operator/parser/severity/config_test.go
Expand Up @@ -46,10 +46,6 @@ func TestUnmarshal(t *testing.T) {
return cfg
}(),
},
{
Name: "no_nested",
ExpectErr: true,
},
},
}.Run(t)
}
4 changes: 0 additions & 4 deletions pkg/stanza/operator/parser/time/config_test.go
Expand Up @@ -49,10 +49,6 @@ func TestUnmarshal(t *testing.T) {
return cfg
}(),
},
{
Name: "no_nested",
ExpectErr: true,
},
},
}.Run(t)
}

0 comments on commit f1b3f0c

Please sign in to comment.