Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][exporter/influxdb] Use NewDefaultClientConfig instead of manually creating struct #35521

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions exporter/influxdbexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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,
Expand Down
13 changes: 7 additions & 6 deletions exporter/influxdbexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions exporter/influxdbexporter/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down