Skip to content

Commit f8650e7

Browse files
committed
[exporter/otlphttpexporter] Use NewDefaultClientConfig instead of manually creating struct
This PR makes usage of `NewDefaultClientConfig` instead of manually creating the confighttp.ClientConfig struct. The updates to defaults are maintained (Timeout, Compression, WriteBufferSize) whereas the fields that match the default are not manually set anymore (Endpoint, Headers). Issue: open-telemetry#9478 (comment)
1 parent 9811830 commit f8650e7

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

exporter/otlphttpexporter/factory.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"go.opentelemetry.io/collector/component"
1414
"go.opentelemetry.io/collector/config/configcompression"
1515
"go.opentelemetry.io/collector/config/confighttp"
16-
"go.opentelemetry.io/collector/config/configopaque"
1716
"go.opentelemetry.io/collector/config/configretry"
1817
"go.opentelemetry.io/collector/consumer"
1918
"go.opentelemetry.io/collector/exporter"
@@ -33,19 +32,18 @@ func NewFactory() exporter.Factory {
3332
}
3433

3534
func createDefaultConfig() component.Config {
35+
clientConfig := confighttp.NewDefaultClientConfig()
36+
clientConfig.Timeout = 30 * time.Second
37+
// Default to gzip compression
38+
clientConfig.Compression = configcompression.TypeGzip
39+
// We almost read 0 bytes, so no need to tune ReadBufferSize.
40+
clientConfig.WriteBufferSize = 512 * 1024
41+
3642
return &Config{
37-
RetryConfig: configretry.NewDefaultBackOffConfig(),
38-
QueueConfig: exporterhelper.NewDefaultQueueConfig(),
39-
Encoding: EncodingProto,
40-
ClientConfig: confighttp.ClientConfig{
41-
Endpoint: "",
42-
Timeout: 30 * time.Second,
43-
Headers: map[string]configopaque.String{},
44-
// Default to gzip compression
45-
Compression: configcompression.TypeGzip,
46-
// We almost read 0 bytes, so no need to tune ReadBufferSize.
47-
WriteBufferSize: 512 * 1024,
48-
},
43+
RetryConfig: configretry.NewDefaultBackOffConfig(),
44+
QueueConfig: exporterhelper.NewDefaultQueueConfig(),
45+
Encoding: EncodingProto,
46+
ClientConfig: clientConfig,
4947
}
5048
}
5149

0 commit comments

Comments
 (0)