Without unmarshal I get this
sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
assert.NoError(t, component.ValidateConfig(cfg))
if diff := cmp.Diff(tt.expected, cfg, cmpopts.IgnoreUnexported(metadata.MetricsBuilderConfig{}), cmpopts.IgnoreUnexported(metadata.MetricSettings{})); diff != "" {
t.Errorf("Config mismatch (-expected +actual):\n%s", diff)
}
Which uses he default unmarshaler
// UnmarshalConfig helper function to UnmarshalConfig a Config.
// It checks if the config implements confmap.Unmarshaler and uses that if available,
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
func UnmarshalConfig(conf *confmap.Conf, intoCfg Config) error {
if cu, ok := intoCfg.(confmap.Unmarshaler); ok {
return cu.Unmarshal(conf)
}
return conf.Unmarshal(intoCfg, confmap.WithErrorUnused())
}
this all gives the following error
--- FAIL: TestLoadConfig (0.00s)
--- FAIL: TestLoadConfig/active_directory_ds (0.00s)
config_test.go:67:
Error Trace: /home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver/config_test.go:67
Error: Received unexpected error:
1 error(s) decoding:
* '' has invalid keys: collection_interval
Test: TestLoadConfig/active_directory_ds
Tests pass with this:
func (cfg *Config) Unmarshal(parser *confmap.Conf) error {
if parser == nil {
return nil
}
err := parser.Unmarshal(cfg) // , confmap.WithErrorUnused()) // , cmpopts.IgnoreUnexported(metadata.MetricSettings{}))
if err != nil {
return err
}
return nil
}
giving the output
❯ make gotest
make for-all-target TARGET="test"
make[1]: Entering directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib'
Running target 'test' in module 'receiver/activedirectorydsreceiver' as part of group 'all'
make -C receiver/activedirectorydsreceiver test
make[2]: Entering directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver'
if [ "" = "true" ]; then \
go test -race -timeout 300s -parallel 4 --tags="" -v ./... 2>&1 | tee -a ./foresight-test-report.txt; \
else \
go test -race -timeout 300s -parallel 4 --tags="" ./...; \
fi
ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver 0.049s
ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver/internal/metadata (cached)
make[2]: Leaving directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver'
Running target 'test' in module 'receiver/aerospikereceiver' as part of group 'all'
make -C receiver/aerospikereceiver test
make[2]: Entering directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/aerospikereceiver'
if [ "" = "true" ]; then \
go test -race -timeout 300s -parallel 4 --tags="" -v ./... 2>&1 | tee -a ./foresight-test-
and it'll continue to run until
Running target 'test' in module 'receiver/bigipreceiver' as part of group 'all'
make -C receiver/bigipreceiver test
make[2]: Entering directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/bigipreceiver'
if [ "" = "true" ]; then \
go test -race -timeout 300s -parallel 4 --tags="" -v ./... 2>&1 | tee -a ./foresight-test-report.txt; \
else \
go test -race -timeout 300s -parallel 4 --tags="" ./...; \
fi
--- FAIL: TestLoadConfig (0.00s)
config_test.go:140:
Error Trace: /home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/bigipreceiver/config_test.go:140
Error: Received unexpected error:
1 error(s) decoding:
* '' has invalid keys: collection_interval, endpoint, password, tls, username
Test: TestLoadConfig
which shows it's an issue in unmarshaling. Adding confmap
to the bigip receiver's gomod will do this:
Running target 'test' in module 'receiver/bigipreceiver' as part of group 'all'
make -C receiver/bigipreceiver test
make[2]: Entering directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/bigipreceiver'
if [ "" = "true" ]; then \
go test -race -timeout 300s -parallel 4 --tags="" -v ./... 2>&1 | tee -a ./foresight-test-report.txt; \
else \
go test -race -timeout 300s -parallel 4 --tags="" ./...; \
fi
ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/bigipreceiver 0.199s
ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/bigipreceiver/internal/metadata 0.066s
? github.com/open-telemetry/opentelemetry-collector-contrib/receiver/bigipreceiver/internal/mocks [no test files]
? github.com/open-telemetry/opentelemetry-collector-contrib/receiver/bigipreceiver/internal/models [no test files]
make[2]: Leaving directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/bigipreceiver'
Running target 'test' in module 'receiver/carbonreceiver' as part of group 'all'
make -C receiver/carbonreceiver test
make[2]: Entering directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/carbonreceiver'
if [ "" = "true" ]; then \
go test -race -timeout 300s -parallel 4 --tags="" -v ./... 2>&1 | tee -a ./foresight-test-report.txt; \
else \
go test -race -timeout 300s -parallel 4 --tags="" ./...; \
fi
ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver 0.057s
ok github.com/open-telemetry/opentelemetry-collec
until it fails with another config parse issue at
make[2]: Leaving directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/carbonreceiver'
Running target 'test' in module 'receiver/chronyreceiver' as part of group 'all'
make -C receiver/chronyreceiver test
make[2]: Entering directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/chronyreceiver'
if [ "" = "true" ]; then \
go test -race -timeout 300s -parallel 4 --tags="" -v ./... 2>&1 | tee -a ./foresight-test-report.txt; \
else \
go test -race -timeout 300s -parallel 4 --tags="" ./...; \
fi
--- FAIL: TestLoadConfig (0.00s)
config_test.go:45:
Error Trace: /home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/chronyreceiver/config_test.go:45
Error: Received unexpected error:
1 error(s) decoding:
* '' has invalid keys: endpoint, timeout
Test: TestLoadConfig
FAIL
FAIL github.com/open-telemetry/opentelemetry-collector-contrib/receiver/chronyreceiver 0.023s
ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/chronyreceiver/internal/chrony 0.139s
ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/chronyreceiver/internal/metadata 0.045s
FAIL
make[2]: *** [../../Makefile.Common:98: test] Error 1
make[2]: Leaving directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib/receiver/chronyreceiver'
make[1]: *** [Makefile:167: receiver/chronyreceiver] Error 2
make[1]: Leaving directory '/home/jameshughes/workspace/unison/otel-github/opentelemetry-collector-contrib'
make: *** [Makefile:97: gotest] Error 2
~/works/u/o/opentelemetry-collector-contrib MetricsSetti…shal_no_with !6 ?2
Alright, reset my state. I got things building when removing the custom
Unmarshal
s forMetricsBuilderConfig
andResourceAttributesSettings
inmdatagen
'smetrics.go.tmpl
. This is fine for now, but if we ever want to addenabledSetbyUser
fortype ResourceAttributeSettings
, we'll need to add anUnmarshal
back forResourceAttributeSettings
lest we get the expected error