Skip to content

Commit

Permalink
Remove deprecated fields from OTel ResolverSettings (#4803)
Browse files Browse the repository at this point in the history
The `Providers` and `Converters` fields of `ResolverSettings` struct
were deprecated in [v0.99.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.99.0) (open-telemetry/opentelemetry-collector#9516)
and removed in [v0.101.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.101.0).
This refactoring is required before updating to OTel v0.101.0.
  • Loading branch information
andrzej-stencel authored May 29, 2024
1 parent e984ed2 commit cb7e377
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions internal/pkg/otel/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@ func newSettings(version string, configPaths []string) (*otelcol.CollectorSettin
Description: buildDescription,
Version: version,
}
converterSet := confmap.ConverterSettings{}
configProviderSettings := otelcol.ConfigProviderSettings{
ResolverSettings: confmap.ResolverSettings{
URIs: configPaths,
Providers: makeMapProvidersMap(
fileprovider.NewWithSettings(confmap.ProviderSettings{}),
envprovider.NewWithSettings(confmap.ProviderSettings{}),
yamlprovider.NewWithSettings(confmap.ProviderSettings{}),
httpprovider.NewWithSettings(confmap.ProviderSettings{}),
httpsprovider.NewWithSettings(confmap.ProviderSettings{}),
),
Converters: []confmap.Converter{expandconverter.New(converterSet)},
ProviderFactories: []confmap.ProviderFactory{
fileprovider.NewFactory(),
envprovider.NewFactory(),
yamlprovider.NewFactory(),
httpprovider.NewFactory(),
httpsprovider.NewFactory(),
},
ConverterFactories: []confmap.ConverterFactory{
expandconverter.NewFactory(),
},
},
}
provider, err := otelcol.NewConfigProvider(configProviderSettings)
Expand All @@ -81,11 +82,3 @@ func newSettings(version string, configPaths []string) (*otelcol.CollectorSettin
DisableGracefulShutdown: true,
}, nil
}

func makeMapProvidersMap(providers ...confmap.Provider) map[string]confmap.Provider {
ret := make(map[string]confmap.Provider, len(providers))
for _, provider := range providers {
ret[provider.Scheme()] = provider
}
return ret
}

0 comments on commit cb7e377

Please sign in to comment.