7
7
"context"
8
8
"path/filepath"
9
9
"testing"
10
+ "time"
10
11
11
12
"github.com/stretchr/testify/assert"
12
13
"github.com/stretchr/testify/require"
@@ -19,6 +20,7 @@ import (
19
20
"go.opentelemetry.io/collector/config/configtls"
20
21
"go.opentelemetry.io/collector/confmap/confmaptest"
21
22
"go.opentelemetry.io/collector/confmap/xconfmap"
23
+ "go.opentelemetry.io/collector/exporter/exporterbatcher"
22
24
"go.opentelemetry.io/collector/exporter/exporterhelper"
23
25
"go.opentelemetry.io/collector/exporter/exportertest"
24
26
"go.opentelemetry.io/collector/pdata/pcommon"
@@ -89,6 +91,13 @@ func TestLoadConfig(t *testing.T) {
89
91
},
90
92
BalancerName : "" ,
91
93
},
94
+ BatcherConfig : exporterbatcher.Config {
95
+ Enabled : false ,
96
+ FlushTimeout : 200 * time .Millisecond ,
97
+ MinSizeConfig : exporterbatcher.MinSizeConfig {
98
+ MinSizeItems : 8192 ,
99
+ },
100
+ },
92
101
},
93
102
},
94
103
{
@@ -146,6 +155,13 @@ func TestLoadConfig(t *testing.T) {
146
155
},
147
156
BalancerName : "" ,
148
157
},
158
+ BatcherConfig : exporterbatcher.Config {
159
+ Enabled : true ,
160
+ FlushTimeout : 3 * time .Second ,
161
+ MinSizeConfig : exporterbatcher.MinSizeConfig {
162
+ MinSizeItems : 8888 ,
163
+ },
164
+ },
149
165
},
150
166
},
151
167
}
@@ -315,3 +331,38 @@ func TestGetMetadataFromResource(t *testing.T) {
315
331
assert .Equal (t , "application" , appName )
316
332
assert .Equal (t , "subsystem" , subSystemName )
317
333
}
334
+
335
+ func TestCreateExportersWithBatcher (t * testing.T ) {
336
+ factory := NewFactory ()
337
+ cfg := factory .CreateDefaultConfig ().(* Config )
338
+ cfg .Domain = "localhost"
339
+ cfg .PrivateKey = "test-key"
340
+ cfg .AppName = "test-app"
341
+ cfg .BatcherConfig .Enabled = true
342
+ cfg .BatcherConfig .FlushTimeout = 1 * time .Second
343
+ cfg .BatcherConfig .MinSizeItems = 100
344
+
345
+ // Test traces exporter
346
+ t .Run ("traces_with_batcher" , func (t * testing.T ) {
347
+ set := exportertest .NewNopSettingsWithType (metadata .Type )
348
+ exp , err := factory .CreateTraces (context .Background (), set , cfg )
349
+ require .NoError (t , err )
350
+ require .NotNil (t , exp )
351
+ })
352
+
353
+ // Test metrics exporter
354
+ t .Run ("metrics_with_batcher" , func (t * testing.T ) {
355
+ set := exportertest .NewNopSettingsWithType (metadata .Type )
356
+ exp , err := factory .CreateMetrics (context .Background (), set , cfg )
357
+ require .NoError (t , err )
358
+ require .NotNil (t , exp )
359
+ })
360
+
361
+ // Test logs exporter
362
+ t .Run ("logs_with_batcher" , func (t * testing.T ) {
363
+ set := exportertest .NewNopSettingsWithType (metadata .Type )
364
+ exp , err := factory .CreateLogs (context .Background (), set , cfg )
365
+ require .NoError (t , err )
366
+ require .NotNil (t , exp )
367
+ })
368
+ }
0 commit comments