Skip to content
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

Migrate from otelcoltest.LoadConfigAndValidate to otelcoltest.LoadConfigAndValidateWithSettings #33594

Open
djaglowski opened this issue Jun 17, 2024 · 3 comments
Labels

Comments

@djaglowski
Copy link
Member

Component(s)

No response

Describe the issue you're reporting

otelcoltest.LoadConfigAndValidate is deprecated in favor of otelcoltest.LoadConfigAndValidateWithSettings in the latest core.

@djaglowski djaglowski added the release:blocker The issue must be resolved before cutting the next release label Jun 17, 2024
@djaglowski
Copy link
Member Author

Is there a better way to migrate than changing the following?

- _, err = otelcoltest.LoadConfigAndValidateWithSettings(filepath.Join("testdata", test.file), factories)
- require.ErrorContains(t, err, test.contains)

+ cfg, err := otelcoltest.LoadConfigWithSettings(factories, otelcol.ConfigProviderSettings{
+ 	ResolverSettings: confmap.ResolverSettings{
+ 		URIs: []string{filepath.Join("testdata", test.file)},
+ 		ProviderFactories: []confmap.ProviderFactory{
+ 			fileprovider.NewFactory(),
+ 			envprovider.NewFactory(),
+ 			yamlprovider.NewFactory(),
+ 			httpprovider.NewFactory(),
+ 		},
+ 		ConverterFactories: []confmap.ConverterFactory{expandconverter.NewFactory()},
+ 	},
+ })
+ require.NoError(t, err)
+ require.ErrorContains(t, cfg.Validate(), test.contains)

@TylerHelmuth
Copy link
Member

TylerHelmuth commented Jun 17, 2024

As part of open-telemetry/opentelemetry-collector#10290 we're trying to get providers and converters out of otelcol. Your solution looks correct. Maybe a better experience would be to make otelcoltest its own package so it can import that providers/converters without otelcol needing to.

To unblock the release I see 3 options.

  1. move forward with the current deprecation process and add the ConfigProviderSettings everywhere.
  2. revert the changes made to otelcoltest, duplicate it into a new package, deprecate the otelcoltest that lives in otelcol.
  3. reproduce otelcoltest in contrib's internal, and deal how we want otelcoltest to work later.

Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

@github-actions github-actions bot added the Stale label Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants