diff --git a/exporter/influxdbexporter/config_test.go b/exporter/influxdbexporter/config_test.go index 7bcb99dff6f6..6459d4cad16a 100644 --- a/exporter/influxdbexporter/config_test.go +++ b/exporter/influxdbexporter/config_test.go @@ -22,6 +22,10 @@ import ( ) func TestLoadConfig(t *testing.T) { + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Endpoint = "http://localhost:8080" + clientConfig.Timeout = 500 * time.Millisecond + clientConfig.Headers = map[string]configopaque.String{"User-Agent": "OpenTelemetry -> Influx"} t.Parallel() cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) @@ -38,11 +42,7 @@ func TestLoadConfig(t *testing.T) { { id: component.NewIDWithName(metadata.Type, "override-config"), expected: &Config{ - ClientConfig: confighttp.ClientConfig{ - Endpoint: "http://localhost:8080", - Timeout: 500 * time.Millisecond, - Headers: map[string]configopaque.String{"User-Agent": "OpenTelemetry -> Influx"}, - }, + ClientConfig: clientConfig, QueueSettings: exporterhelper.QueueConfig{ Enabled: true, NumConsumers: 3, diff --git a/exporter/influxdbexporter/factory.go b/exporter/influxdbexporter/factory.go index fabf1a5787c1..d9cfa42ae311 100644 --- a/exporter/influxdbexporter/factory.go +++ b/exporter/influxdbexporter/factory.go @@ -34,13 +34,14 @@ func NewFactory() exporter.Factory { } func createDefaultConfig() component.Config { + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Timeout = 5 * time.Second + clientConfig.Headers = map[string]configopaque.String{ + "User-Agent": "OpenTelemetry -> Influx", + } + return &Config{ - ClientConfig: confighttp.ClientConfig{ - Timeout: 5 * time.Second, - Headers: map[string]configopaque.String{ - "User-Agent": "OpenTelemetry -> Influx", - }, - }, + ClientConfig: clientConfig, QueueSettings: exporterhelper.NewDefaultQueueConfig(), BackOffConfig: configretry.NewDefaultBackOffConfig(), MetricsSchema: common.MetricsSchemaTelegrafPrometheusV1.String(), diff --git a/exporter/influxdbexporter/writer_test.go b/exporter/influxdbexporter/writer_test.go index 36fdffa3bbd4..8970bf6b29dc 100644 --- a/exporter/influxdbexporter/writer_test.go +++ b/exporter/influxdbexporter/writer_test.go @@ -158,13 +158,13 @@ func Test_influxHTTPWriterBatch_EnqueuePoint_emptyTagValue(t *testing.T) { t.Cleanup(noopHTTPServer.Close) nowTime := time.Unix(1000, 2000) + clientConfig := confighttp.NewDefaultClientConfig() + clientConfig.Endpoint = noopHTTPServer.URL influxWriter, err := newInfluxHTTPWriter( new(common.NoopLogger), &Config{ - ClientConfig: confighttp.ClientConfig{ - Endpoint: noopHTTPServer.URL, - }, + ClientConfig: clientConfig, }, componenttest.NewNopTelemetrySettings()) require.NoError(t, err)