diff --git a/exporter/awsprometheusremotewriteexporter/auth_test.go b/exporter/awsprometheusremotewriteexporter/auth_test.go index 71573ca56fa4..f1d643406d58 100644 --- a/exporter/awsprometheusremotewriteexporter/auth_test.go +++ b/exporter/awsprometheusremotewriteexporter/auth_test.go @@ -64,7 +64,7 @@ func TestRequestSignature(t *testing.T) { return newSigningRoundTripperWithCredentials(authConfig, awsCreds, next, sdkInformation) }, } - client, _ := setting.ToClient(componenttest.NewNopHost().GetExtensions(), componenttest.NewNopTelemetrySettings()) + client, _ := setting.ToClientWithHost(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) req, err := http.NewRequest("POST", setting.Endpoint, strings.NewReader("a=1&b=2")) assert.NoError(t, err) _, err = client.Do(req) @@ -97,7 +97,7 @@ func TestRequestSignatureEmptyBody(t *testing.T) { return newSigningRoundTripperWithCredentials(authConfig, awsCreds, next, sdkInformation) }, } - client, _ := setting.ToClient(componenttest.NewNopHost().GetExtensions(), componenttest.NewNopTelemetrySettings()) + client, _ := setting.ToClientWithHost(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) req, err := http.NewRequest("GET", setting.Endpoint, nil) assert.NoError(t, err) _, err = client.Do(req) @@ -143,7 +143,7 @@ func TestLeakingBody(t *testing.T) { return newSigningRoundTripperWithCredentials(authConfig, awsCreds, next, sdkInformation) }, } - client, _ := setting.ToClient(componenttest.NewNopHost().GetExtensions(), componenttest.NewNopTelemetrySettings()) + client, _ := setting.ToClientWithHost(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) checker := &checkCloser{Reader: strings.NewReader("a=1&b=2")} req, err := http.NewRequest("POST", setting.Endpoint, checker) assert.NoError(t, err) diff --git a/exporter/dynatraceexporter/metrics_exporter.go b/exporter/dynatraceexporter/metrics_exporter.go index 19c8edb95411..01f993782d38 100644 --- a/exporter/dynatraceexporter/metrics_exporter.go +++ b/exporter/dynatraceexporter/metrics_exporter.go @@ -281,7 +281,7 @@ func (e *exporter) sendBatch(ctx context.Context, lines []string) error { // start starts the exporter func (e *exporter) start(_ context.Context, host component.Host) (err error) { - client, err := e.cfg.HTTPClientSettings.ToClient(host.GetExtensions(), e.settings) + client, err := e.cfg.HTTPClientSettings.ToClientWithHost(host, e.settings) if err != nil { e.settings.Logger.Error("Failed to construct HTTP client", zap.Error(err)) return fmt.Errorf("start: %w", err) diff --git a/exporter/humioexporter/humio_client.go b/exporter/humioexporter/humio_client.go index 64c7af2a0d78..a23553e87059 100644 --- a/exporter/humioexporter/humio_client.go +++ b/exporter/humioexporter/humio_client.go @@ -107,7 +107,7 @@ type humioClient struct { // Constructs a new HTTP client for sending payloads to Humio func newHumioClient(cfg *Config, settings component.TelemetrySettings, host component.Host) (exporterClient, error) { - client, err := cfg.HTTPClientSettings.ToClient(host.GetExtensions(), settings) + client, err := cfg.HTTPClientSettings.ToClientWithHost(host, settings) if err != nil { return nil, err } diff --git a/exporter/influxdbexporter/writer.go b/exporter/influxdbexporter/writer.go index 88b08805bdd2..37a1d6d6a327 100644 --- a/exporter/influxdbexporter/writer.go +++ b/exporter/influxdbexporter/writer.go @@ -60,7 +60,7 @@ func newInfluxHTTPWriter(logger common.Logger, config *Config, host component.Ho config.HTTPClientSettings.Headers["Authorization"] = "Token " + config.Token } - httpClient, err := config.HTTPClientSettings.ToClient(host.GetExtensions(), settings) + httpClient, err := config.HTTPClientSettings.ToClientWithHost(host, settings) if err != nil { return nil, err } diff --git a/exporter/jaegerthrifthttpexporter/exporter.go b/exporter/jaegerthrifthttpexporter/exporter.go index 60ec8e5068fb..124e94e74668 100644 --- a/exporter/jaegerthrifthttpexporter/exporter.go +++ b/exporter/jaegerthrifthttpexporter/exporter.go @@ -61,7 +61,7 @@ type jaegerThriftHTTPSender struct { // start starts the exporter func (s *jaegerThriftHTTPSender) start(_ context.Context, host component.Host) (err error) { - s.client, err = s.config.HTTPClientSettings.ToClient(host.GetExtensions(), s.settings) + s.client, err = s.config.HTTPClientSettings.ToClientWithHost(host, s.settings) if err != nil { return consumererror.NewPermanent(err) diff --git a/exporter/logzioexporter/exporter.go b/exporter/logzioexporter/exporter.go index 8aedd7b10581..2e5fba122a2b 100644 --- a/exporter/logzioexporter/exporter.go +++ b/exporter/logzioexporter/exporter.go @@ -29,15 +29,14 @@ import ( "github.com/hashicorp/go-hclog" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/cache" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer/consumererror" + "go.opentelemetry.io/collector/exporter/exporterhelper" "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/ptrace" "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/protobuf/proto" - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/exporter/exporterhelper" - "go.opentelemetry.io/collector/pdata/ptrace" - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger" ) @@ -127,7 +126,7 @@ func newLogzioLogsExporter(config *Config, set component.ExporterCreateSettings) } func (exporter *logzioExporter) start(_ context.Context, host component.Host) error { - client, err := exporter.config.HTTPClientSettings.ToClient(host.GetExtensions(), exporter.settings) + client, err := exporter.config.HTTPClientSettings.ToClientWithHost(host, exporter.settings) if err != nil { return err } diff --git a/exporter/lokiexporter/exporter.go b/exporter/lokiexporter/exporter.go index 2424ea63e5fc..482ad7972fea 100644 --- a/exporter/lokiexporter/exporter.go +++ b/exporter/lokiexporter/exporter.go @@ -156,7 +156,7 @@ func encode(pb proto.Message) ([]byte, error) { } func (l *lokiExporter) start(_ context.Context, host component.Host) (err error) { - client, err := l.config.HTTPClientSettings.ToClient(host.GetExtensions(), l.settings) + client, err := l.config.HTTPClientSettings.ToClientWithHost(host, l.settings) if err != nil { return err } diff --git a/exporter/mezmoexporter/exporter.go b/exporter/mezmoexporter/exporter.go index ed2fe34ac3a1..1dd37c49be81 100644 --- a/exporter/mezmoexporter/exporter.go +++ b/exporter/mezmoexporter/exporter.go @@ -69,7 +69,7 @@ func (m *mezmoExporter) pushLogData(ctx context.Context, ld plog.Logs) error { } func (m *mezmoExporter) start(_ context.Context, host component.Host) (err error) { - m.client, err = m.config.HTTPClientSettings.ToClient(host.GetExtensions(), m.settings) + m.client, err = m.config.HTTPClientSettings.ToClientWithHost(host, m.settings) return err } diff --git a/exporter/prometheusremotewriteexporter/exporter.go b/exporter/prometheusremotewriteexporter/exporter.go index 7134e4466b9e..e4c92bb36250 100644 --- a/exporter/prometheusremotewriteexporter/exporter.go +++ b/exporter/prometheusremotewriteexporter/exporter.go @@ -96,7 +96,7 @@ func newPRWExporter(cfg *Config, set component.ExporterCreateSettings) (*prwExpo // Start creates the prometheus client func (prwe *prwExporter) Start(ctx context.Context, host component.Host) (err error) { - prwe.client, err = prwe.clientSettings.ToClient(host.GetExtensions(), prwe.settings) + prwe.client, err = prwe.clientSettings.ToClientWithHost(host, prwe.settings) if err != nil { return err } diff --git a/exporter/signalfxexporter/internal/correlation/correlation.go b/exporter/signalfxexporter/internal/correlation/correlation.go index f6843c2281a0..2981040cb126 100644 --- a/exporter/signalfxexporter/internal/correlation/correlation.go +++ b/exporter/signalfxexporter/internal/correlation/correlation.go @@ -65,7 +65,7 @@ func newCorrelationClient(cfg *Config, accessToken string, params component.Expo return nil, fmt.Errorf("failed to parse correlation endpoint URL %q: %w", cfg.Endpoint, err) } - httpClient, err := cfg.ToClient(host.GetExtensions(), params.TelemetrySettings) + httpClient, err := cfg.ToClientWithHost(host, params.TelemetrySettings) if err != nil { return nil, fmt.Errorf("failed to create correlation API client: %w", err) } diff --git a/exporter/sumologicexporter/exporter.go b/exporter/sumologicexporter/exporter.go index bb5c9c9e51cf..3b80d596839f 100644 --- a/exporter/sumologicexporter/exporter.go +++ b/exporter/sumologicexporter/exporter.go @@ -112,7 +112,7 @@ func newMetricsExporter( // start starts the exporter func (se *sumologicexporter) start(_ context.Context, host component.Host) (err error) { - client, err := se.config.HTTPClientSettings.ToClient(host.GetExtensions(), se.settings) + client, err := se.config.HTTPClientSettings.ToClientWithHost(host, se.settings) if err != nil { return fmt.Errorf("failed to create HTTP Client: %w", err) } diff --git a/exporter/zipkinexporter/zipkin.go b/exporter/zipkinexporter/zipkin.go index 4bf40a56ec19..842cc6c9b9b5 100644 --- a/exporter/zipkinexporter/zipkin.go +++ b/exporter/zipkinexporter/zipkin.go @@ -70,7 +70,7 @@ func createZipkinExporter(cfg *Config, settings component.TelemetrySettings) (*z // start creates the http client func (ze *zipkinExporter) start(_ context.Context, host component.Host) (err error) { - ze.client, err = ze.clientSettings.ToClient(host.GetExtensions(), ze.settings) + ze.client, err = ze.clientSettings.ToClientWithHost(host, ze.settings) return } diff --git a/extension/httpforwarder/extension.go b/extension/httpforwarder/extension.go index 07df0fe1318d..46f3b28f9d14 100644 --- a/extension/httpforwarder/extension.go +++ b/extension/httpforwarder/extension.go @@ -42,7 +42,7 @@ func (h *httpForwarder) Start(_ context.Context, host component.Host) error { return fmt.Errorf("failed to bind to address %s: %w", h.config.Ingress.Endpoint, err) } - httpClient, err := h.config.Egress.ToClient(host.GetExtensions(), h.settings) + httpClient, err := h.config.Egress.ToClientWithHost(host, h.settings) if err != nil { return fmt.Errorf("failed to create HTTP Client: %w", err) } diff --git a/extension/oauth2clientauthextension/extension_test.go b/extension/oauth2clientauthextension/extension_test.go index 7d7a84636e4c..3dedb03a774b 100644 --- a/extension/oauth2clientauthextension/extension_test.go +++ b/extension/oauth2clientauthextension/extension_test.go @@ -289,7 +289,7 @@ func TestFailContactingOAuth(t *testing.T) { }, } - client, _ := setting.ToClient(componenttest.NewNopHost().GetExtensions(), componenttest.NewNopTelemetrySettings()) + client, _ := setting.ToClientWithHost(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) req, err := http.NewRequest("POST", setting.Endpoint, nil) assert.NoError(t, err) _, err = client.Do(req) diff --git a/processor/resourcedetectionprocessor/resourcedetection_processor.go b/processor/resourcedetectionprocessor/resourcedetection_processor.go index 91a3cf04f85e..9ed997d12a81 100644 --- a/processor/resourcedetectionprocessor/resourcedetection_processor.go +++ b/processor/resourcedetectionprocessor/resourcedetection_processor.go @@ -38,7 +38,7 @@ type resourceDetectionProcessor struct { // Start is invoked during service startup. func (rdp *resourceDetectionProcessor) Start(ctx context.Context, host component.Host) error { - client, _ := rdp.httpClientSettings.ToClient(host.GetExtensions(), rdp.telemetrySettings) + client, _ := rdp.httpClientSettings.ToClientWithHost(host, rdp.telemetrySettings) ctx = internal.ContextWithClient(ctx, client) var err error rdp.resource, rdp.schemaURL, err = rdp.provider.Get(ctx, client) diff --git a/receiver/apachereceiver/scraper.go b/receiver/apachereceiver/scraper.go index 80b57ec73ea0..520b53960581 100644 --- a/receiver/apachereceiver/scraper.go +++ b/receiver/apachereceiver/scraper.go @@ -51,7 +51,7 @@ func newApacheScraper( } func (r *apacheScraper) start(_ context.Context, host component.Host) error { - httpClient, err := r.cfg.ToClient(host.GetExtensions(), r.settings) + httpClient, err := r.cfg.ToClientWithHost(host, r.settings) if err != nil { return err } diff --git a/receiver/awscontainerinsightreceiver/internal/ecsInfo/ecsinfo.go b/receiver/awscontainerinsightreceiver/internal/ecsInfo/ecsinfo.go index 40173c8c67f2..f22dbf3d0c49 100644 --- a/receiver/awscontainerinsightreceiver/internal/ecsInfo/ecsinfo.go +++ b/receiver/awscontainerinsightreceiver/internal/ecsInfo/ecsinfo.go @@ -19,7 +19,6 @@ import ( "time" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/config/confighttp" "go.uber.org/zap" ) @@ -91,13 +90,12 @@ func (e *EcsInfo) GetClusterName() string { type ecsInfoOption func(*EcsInfo) // New creates a k8sApiServer which can generate cluster-level metrics -func NewECSInfo(refreshInterval time.Duration, hostIPProvider hostIPProvider, settings component.TelemetrySettings, options ...ecsInfoOption) (*EcsInfo, error) { - +func NewECSInfo(refreshInterval time.Duration, hostIPProvider hostIPProvider, host component.Host, settings component.TelemetrySettings, options ...ecsInfoOption) (*EcsInfo, error) { setting := confighttp.HTTPClientSettings{ Timeout: defaultTimeout, } - client, err := setting.ToClient(map[config.ComponentID]component.Extension{}, settings) + client, err := setting.ToClientWithHost(host, settings) if err != nil { settings.Logger.Warn("Failed to create a http client for ECS info!") diff --git a/receiver/awscontainerinsightreceiver/internal/ecsInfo/ecsinfo_test.go b/receiver/awscontainerinsightreceiver/internal/ecsInfo/ecsinfo_test.go index 1af5dd589088..a154398015b0 100644 --- a/receiver/awscontainerinsightreceiver/internal/ecsInfo/ecsinfo_test.go +++ b/receiver/awscontainerinsightreceiver/internal/ecsInfo/ecsinfo_test.go @@ -118,7 +118,7 @@ func TestNewECSInfo(t *testing.T) { } hostIPProvider := &FakehostInfo{} - ecsinfo, _ := NewECSInfo(time.Minute, hostIPProvider, componenttest.NewNopTelemetrySettings(), containerInstanceInfoCreatorOpt, taskinfoCreatorOpt, cgroupScannerCreatorOpt) + ecsinfo, _ := NewECSInfo(time.Minute, hostIPProvider, componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings(), containerInstanceInfoCreatorOpt, taskinfoCreatorOpt, cgroupScannerCreatorOpt) assert.NotNil(t, ecsinfo) <-ecsinfo.taskInfoTestReadyC diff --git a/receiver/awscontainerinsightreceiver/receiver.go b/receiver/awscontainerinsightreceiver/receiver.go index e417efea92a4..3866bb2c31a9 100644 --- a/receiver/awscontainerinsightreceiver/receiver.go +++ b/receiver/awscontainerinsightreceiver/receiver.go @@ -93,7 +93,7 @@ func (acir *awsContainerInsightReceiver) Start(ctx context.Context, host compone } if acir.config.ContainerOrchestrator == ci.ECS { - ecsInfo, err := ecsinfo.NewECSInfo(acir.config.CollectionInterval, hostinfo, acir.settings) + ecsInfo, err := ecsinfo.NewECSInfo(acir.config.CollectionInterval, hostinfo, host, acir.settings) if err != nil { return err } diff --git a/receiver/bigipreceiver/client.go b/receiver/bigipreceiver/client.go index 6314dd9bcfe0..4738ce815ec8 100644 --- a/receiver/bigipreceiver/client.go +++ b/receiver/bigipreceiver/client.go @@ -87,7 +87,7 @@ var _ client = (*bigipClient)(nil) // newClient creates an initialized client (but with no token) func newClient(cfg *Config, host component.Host, settings component.TelemetrySettings, logger *zap.Logger) (client, error) { - httpClient, err := cfg.ToClient(host.GetExtensions(), settings) + httpClient, err := cfg.ToClientWithHost(host, settings) if err != nil { return nil, fmt.Errorf("failed to create HTTP Client: %w", err) } diff --git a/receiver/cloudfoundryreceiver/stream.go b/receiver/cloudfoundryreceiver/stream.go index 47590f7bf6e8..7a27bd4722d6 100644 --- a/receiver/cloudfoundryreceiver/stream.go +++ b/receiver/cloudfoundryreceiver/stream.go @@ -38,7 +38,7 @@ func newEnvelopeStreamFactory( httpConfig confighttp.HTTPClientSettings, host component.Host) (*EnvelopeStreamFactory, error) { - httpClient, err := httpConfig.ToClient(host.GetExtensions(), settings) + httpClient, err := httpConfig.ToClientWithHost(host, settings) if err != nil { return nil, fmt.Errorf("creating HTTP client for Cloud Foundry RLP Gateway: %w", err) } diff --git a/receiver/couchdbreceiver/client.go b/receiver/couchdbreceiver/client.go index c2a3d5edc07a..dccedd0b18d9 100644 --- a/receiver/couchdbreceiver/client.go +++ b/receiver/couchdbreceiver/client.go @@ -41,7 +41,7 @@ type couchDBClient struct { // newCouchDBClient creates a new client to make requests for the CouchDB receiver. func newCouchDBClient(cfg *Config, host component.Host, settings component.TelemetrySettings) (client, error) { - client, err := cfg.ToClient(host.GetExtensions(), settings) + client, err := cfg.ToClientWithHost(host, settings) if err != nil { return nil, fmt.Errorf("failed to create HTTP Client: %w", err) } diff --git a/receiver/elasticsearchreceiver/client.go b/receiver/elasticsearchreceiver/client.go index 8ef4ceadd476..44e930da8073 100644 --- a/receiver/elasticsearchreceiver/client.go +++ b/receiver/elasticsearchreceiver/client.go @@ -54,7 +54,7 @@ type defaultElasticsearchClient struct { var _ elasticsearchClient = (*defaultElasticsearchClient)(nil) func newElasticsearchClient(settings component.TelemetrySettings, c Config, h component.Host) (*defaultElasticsearchClient, error) { - client, err := c.HTTPClientSettings.ToClient(h.GetExtensions(), settings) + client, err := c.HTTPClientSettings.ToClientWithHost(h, settings) if err != nil { return nil, err } diff --git a/receiver/expvarreceiver/scraper.go b/receiver/expvarreceiver/scraper.go index 8c3d06dcbb3d..f899e35e16e5 100644 --- a/receiver/expvarreceiver/scraper.go +++ b/receiver/expvarreceiver/scraper.go @@ -51,7 +51,7 @@ func newExpVarScraper(cfg *Config, set component.ReceiverCreateSettings) *expVar } func (e *expVarScraper) start(_ context.Context, host component.Host) error { - client, err := e.cfg.HTTPClientSettings.ToClient(host.GetExtensions(), e.set.TelemetrySettings) + client, err := e.cfg.HTTPClientSettings.ToClientWithHost(host, e.set.TelemetrySettings) if err != nil { return err } diff --git a/receiver/flinkmetricsreceiver/client.go b/receiver/flinkmetricsreceiver/client.go index 0163ab8daddc..405b8df1d8ff 100644 --- a/receiver/flinkmetricsreceiver/client.go +++ b/receiver/flinkmetricsreceiver/client.go @@ -66,7 +66,7 @@ type flinkClient struct { } func newClient(cfg *Config, host component.Host, settings component.TelemetrySettings, logger *zap.Logger) (client, error) { - httpClient, err := cfg.ToClient(host.GetExtensions(), settings) + httpClient, err := cfg.ToClientWithHost(host, settings) if err != nil { return nil, fmt.Errorf("failed to create HTTP Client: %w", err) } diff --git a/receiver/nginxreceiver/scraper.go b/receiver/nginxreceiver/scraper.go index abda67b4c02f..e2f5826d299e 100644 --- a/receiver/nginxreceiver/scraper.go +++ b/receiver/nginxreceiver/scraper.go @@ -49,7 +49,7 @@ func newNginxScraper( } func (r *nginxScraper) start(_ context.Context, host component.Host) error { - httpClient, err := r.cfg.ToClient(host.GetExtensions(), r.settings) + httpClient, err := r.cfg.ToClientWithHost(host, r.settings) if err != nil { return err } diff --git a/receiver/nsxtreceiver/client.go b/receiver/nsxtreceiver/client.go index c4c0127da0f5..1f12111b7eed 100644 --- a/receiver/nsxtreceiver/client.go +++ b/receiver/nsxtreceiver/client.go @@ -51,7 +51,7 @@ var ( ) func newClient(c *Config, settings component.TelemetrySettings, host component.Host, logger *zap.Logger) (*nsxClient, error) { - client, err := c.HTTPClientSettings.ToClient(host.GetExtensions(), settings) + client, err := c.HTTPClientSettings.ToClientWithHost(host, settings) if err != nil { return nil, err } diff --git a/receiver/rabbitmqreceiver/client.go b/receiver/rabbitmqreceiver/client.go index c647132a6dc6..aad8010923f8 100644 --- a/receiver/rabbitmqreceiver/client.go +++ b/receiver/rabbitmqreceiver/client.go @@ -50,7 +50,7 @@ type rabbitmqCredentials struct { } func newClient(cfg *Config, host component.Host, settings component.TelemetrySettings, logger *zap.Logger) (client, error) { - httpClient, err := cfg.ToClient(host.GetExtensions(), settings) + httpClient, err := cfg.ToClientWithHost(host, settings) if err != nil { return nil, fmt.Errorf("failed to create HTTP Client: %w", err) } diff --git a/receiver/riakreceiver/client.go b/receiver/riakreceiver/client.go index 5e5a12e8b1b3..0588b209f83c 100644 --- a/receiver/riakreceiver/client.go +++ b/receiver/riakreceiver/client.go @@ -50,7 +50,7 @@ type riakCredentials struct { } func newClient(cfg *Config, host component.Host, settings component.TelemetrySettings, logger *zap.Logger) (client, error) { - httpClient, err := cfg.ToClient(host.GetExtensions(), settings) + httpClient, err := cfg.ToClientWithHost(host, settings) if err != nil { return nil, fmt.Errorf("failed to create HTTP Client: %w", err) }