diff --git a/receiver/prometheusreceiver/internal/staleness_end_to_end_test.go b/receiver/prometheusreceiver/internal/staleness_end_to_end_test.go index db9f23d24887..c92628385409 100644 --- a/receiver/prometheusreceiver/internal/staleness_end_to_end_test.go +++ b/receiver/prometheusreceiver/internal/staleness_end_to_end_test.go @@ -34,6 +34,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config" + "go.opentelemetry.io/collector/config/configunmarshaler" + "go.opentelemetry.io/collector/config/mapprovider/filemapprovider" "go.opentelemetry.io/collector/processor/batchprocessor" "go.opentelemetry.io/collector/service" "go.uber.org/zap" @@ -113,7 +116,7 @@ jvm_memory_pool_bytes_used{pool="CodeHeap 'non-nmethods'"} %.1f`, float64(i)) defer prweServer.Close() // 3. Set the OpenTelemetry Prometheus receiver. - config := fmt.Sprintf(` + cfg := fmt.Sprintf(` receivers: prometheus: config: @@ -141,7 +144,7 @@ service: confFile, err := ioutil.TempFile(os.TempDir(), "conf-") require.Nil(t, err) defer os.Remove(confFile.Name()) - _, err = confFile.Write([]byte(config)) + _, err = confFile.Write([]byte(cfg)) require.Nil(t, err) // 4. Run the OpenTelemetry Collector. receivers, err := component.MakeReceiverFactoryMap(prometheusreceiver.NewFactory()) @@ -157,10 +160,18 @@ service: Processors: processors, } + fmp := filemapprovider.New() + configProvider, err := service.NewConfigProvider( + service.ConfigProviderSettings{ + Locations: []string{confFile.Name()}, + MapProviders: map[string]config.MapProvider{fmp.Scheme(): fmp}, + Unmarshaler: configunmarshaler.NewDefault(), + }) + require.NoError(t, err) + appSettings := service.CollectorSettings{ - Factories: factories, - // TODO: Replace with NewConfigProvider - ConfigProvider: service.MustNewDefaultConfigProvider([]string{confFile.Name()}, nil), // nolint:staticcheck + Factories: factories, + ConfigProvider: configProvider, BuildInfo: component.BuildInfo{ Command: "otelcol", Description: "OpenTelemetry Collector", diff --git a/testbed/testbed/in_process_collector.go b/testbed/testbed/in_process_collector.go index 55dc44d7403e..175e42780834 100644 --- a/testbed/testbed/in_process_collector.go +++ b/testbed/testbed/in_process_collector.go @@ -24,6 +24,9 @@ import ( "github.com/shirou/gopsutil/v3/process" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config" + "go.opentelemetry.io/collector/config/configunmarshaler" + "go.opentelemetry.io/collector/config/mapprovider/filemapprovider" "go.opentelemetry.io/collector/service" ) @@ -67,11 +70,21 @@ func (ipp *inProcessCollector) Start(args StartParams) error { } ipp.configFile = confFile.Name() + fmp := filemapprovider.New() + configProvider, err := service.NewConfigProvider( + service.ConfigProviderSettings{ + Locations: []string{ipp.configFile}, + MapProviders: map[string]config.MapProvider{fmp.Scheme(): fmp}, + Unmarshaler: configunmarshaler.NewDefault(), + }) + if err != nil { + return err + } + settings := service.CollectorSettings{ - BuildInfo: component.NewDefaultBuildInfo(), - Factories: ipp.factories, - // TODO: Replace with NewConfigProvider - ConfigProvider: service.MustNewDefaultConfigProvider([]string{ipp.configFile}, nil), // nolint:staticcheck + BuildInfo: component.NewDefaultBuildInfo(), + Factories: ipp.factories, + ConfigProvider: configProvider, } ipp.svc, err = service.New(settings)