From 702d9547b9d88258936960d77da8f165fe157671 Mon Sep 17 00:00:00 2001 From: Mackenzie <63265430+mackjmr@users.noreply.github.com> Date: Tue, 8 Oct 2024 20:54:34 -0400 Subject: [PATCH] [chore] [receiver/apache] Use confighttp.NewDefaultClientConfig instead of manually creating struct (#35576) **Description:** This PR makes usage of `NewDefaultClientConfig` instead of manually creating the confighttp.ClientConfig struct. **Link to tracking Issue:** #35457 --- receiver/apachereceiver/factory.go | 10 +++++----- receiver/apachereceiver/scraper_test.go | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/receiver/apachereceiver/factory.go b/receiver/apachereceiver/factory.go index 74a0e6e91fb3..dfa28d9a6610 100644 --- a/receiver/apachereceiver/factory.go +++ b/receiver/apachereceiver/factory.go @@ -33,13 +33,13 @@ func NewFactory() receiver.Factory { func createDefaultConfig() component.Config { cfg := scraperhelper.NewDefaultControllerConfig() cfg.CollectionInterval = 10 * time.Second + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Endpoint = defaultEndpoint + clientConfig.Timeout = 10 * time.Second return &Config{ - ControllerConfig: cfg, - ClientConfig: confighttp.ClientConfig{ - Endpoint: defaultEndpoint, - Timeout: 10 * time.Second, - }, + ControllerConfig: cfg, + ClientConfig: clientConfig, MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(), } } diff --git a/receiver/apachereceiver/scraper_test.go b/receiver/apachereceiver/scraper_test.go index beeb1530f7a5..62b8ba4e5fdb 100644 --- a/receiver/apachereceiver/scraper_test.go +++ b/receiver/apachereceiver/scraper_test.go @@ -58,15 +58,15 @@ func TestScraper(t *testing.T) { } func TestScraperFailedStart(t *testing.T) { - sc := newApacheScraper(receivertest.NewNopSettings(), &Config{ - ClientConfig: confighttp.ClientConfig{ - Endpoint: "localhost:8080", - TLSSetting: configtls.ClientConfig{ - Config: configtls.Config{ - CAFile: "/non/existent", - }, - }, + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Endpoint = "localhost:8080" + clientConfig.TLSSetting = configtls.ClientConfig{ + Config: configtls.Config{ + CAFile: "/non/existent", }, + } + sc := newApacheScraper(receivertest.NewNopSettings(), &Config{ + ClientConfig: clientConfig, }, "localhost", "8080")