@@ -13,7 +13,6 @@ import (
13
13
"go.opentelemetry.io/collector/component"
14
14
"go.opentelemetry.io/collector/config/configcompression"
15
15
"go.opentelemetry.io/collector/config/confighttp"
16
- "go.opentelemetry.io/collector/config/configopaque"
17
16
"go.opentelemetry.io/collector/config/configretry"
18
17
"go.opentelemetry.io/collector/confmap/confmaptest"
19
18
"go.opentelemetry.io/collector/exporter/exporterhelper"
@@ -40,15 +39,11 @@ func TestLoadConfig(t *testing.T) {
40
39
expected .BackOffConfig .MaxInterval = 5 * time .Second
41
40
expected .QueueSettings = exporterhelper .NewDefaultQueueConfig ()
42
41
expected .QueueSettings .Enabled = false
43
- expected .ClientConfig = confighttp.ClientConfig {
44
- Endpoint : "" ,
45
- Timeout : 30 * time .Second ,
46
- Headers : map [string ]configopaque.String {},
47
- // Default to gzip compression
48
- Compression : configcompression .TypeGzip ,
49
- // We almost read 0 bytes, so no need to tune ReadBufferSize.
50
- WriteBufferSize : 512 * 1024 ,
51
- }
42
+ clientConfig := confighttp .NewDefaultClientConfig ()
43
+ clientConfig .Timeout = 30 * time .Second
44
+ clientConfig .Compression = configcompression .TypeGzip
45
+ clientConfig .WriteBufferSize = 512 * 1024
46
+ expected .ClientConfig = clientConfig
52
47
assert .Equal (t , expected , cfg )
53
48
}
54
49
@@ -67,19 +62,19 @@ func TestDefaultLoadConfig(t *testing.T) {
67
62
}
68
63
expected .BackOffConfig = configretry .NewDefaultBackOffConfig ()
69
64
expected .QueueSettings = exporterhelper .NewDefaultQueueConfig ()
70
- expected .ClientConfig = confighttp.ClientConfig {
71
- Endpoint : "" ,
72
- Timeout : 30 * time .Second ,
73
- Headers : map [string ]configopaque.String {},
74
- // Default to gzip compression
75
- Compression : configcompression .TypeGzip ,
76
- // We almost read 0 bytes, so no need to tune ReadBufferSize.
77
- WriteBufferSize : 512 * 1024 ,
78
- }
65
+ clientConfig := confighttp .NewDefaultClientConfig ()
66
+ clientConfig .Timeout = 30 * time .Second
67
+ clientConfig .Compression = configcompression .TypeGzip
68
+ clientConfig .WriteBufferSize = 512 * 1024
69
+ expected .ClientConfig = clientConfig
79
70
assert .Equal (t , expected , cfg )
80
71
}
81
72
82
73
func TestCheckAndWarnDeprecatedOptions (t * testing.T ) {
74
+ clientConfig := confighttp .NewDefaultClientConfig ()
75
+ clientConfig .Timeout = 10 * time .Second
76
+ clientConfig .Compression = configcompression .TypeGzip
77
+ clientConfig .WriteBufferSize = 512 * 1024
83
78
// Config with legacy options
84
79
actualCfg := & Config {
85
80
QueueSettings : exporterhelper .NewDefaultQueueConfig (),
@@ -88,15 +83,7 @@ func TestCheckAndWarnDeprecatedOptions(t *testing.T) {
88
83
CustomEndpoint : "https://api.example.com" ,
89
84
QueueMaxLength : 10 ,
90
85
DrainInterval : 10 ,
91
- ClientConfig : confighttp.ClientConfig {
92
- Endpoint : "" ,
93
- Timeout : 10 * time .Second ,
94
- Headers : map [string ]configopaque.String {},
95
- // Default to gzip compression
96
- Compression : configcompression .TypeGzip ,
97
- // We almost read 0 bytes, so no need to tune ReadBufferSize.
98
- WriteBufferSize : 512 * 1024 ,
99
- },
86
+ ClientConfig : clientConfig ,
100
87
}
101
88
params := exportertest .NewNopSettings ()
102
89
logger := hclog2ZapLogger {
@@ -105,22 +92,20 @@ func TestCheckAndWarnDeprecatedOptions(t *testing.T) {
105
92
}
106
93
actualCfg .checkAndWarnDeprecatedOptions (& logger )
107
94
95
+ clientConfigEndpoint := confighttp .NewDefaultClientConfig ()
96
+ clientConfigEndpoint .Timeout = 10 * time .Second
97
+ clientConfigEndpoint .Compression = configcompression .TypeGzip
98
+ clientConfigEndpoint .WriteBufferSize = 512 * 1024
99
+ clientConfigEndpoint .Endpoint = "https://api.example.com"
100
+
108
101
expected := & Config {
109
102
Token : "logzioTESTtoken" ,
110
103
CustomEndpoint : "https://api.example.com" ,
111
104
QueueMaxLength : 10 ,
112
105
DrainInterval : 10 ,
113
106
BackOffConfig : configretry .NewDefaultBackOffConfig (),
114
107
QueueSettings : exporterhelper .NewDefaultQueueConfig (),
115
- ClientConfig : confighttp.ClientConfig {
116
- Endpoint : "https://api.example.com" ,
117
- Timeout : 10 * time .Second ,
118
- Headers : map [string ]configopaque.String {},
119
- // Default to gzip compression
120
- Compression : configcompression .TypeGzip ,
121
- // We almost read 0 bytes, so no need to tune ReadBufferSize.
122
- WriteBufferSize : 512 * 1024 ,
123
- },
108
+ ClientConfig : clientConfigEndpoint ,
124
109
}
125
110
expected .QueueSettings .QueueSize = 10
126
111
assert .Equal (t , expected , actualCfg )
0 commit comments