Skip to content

Commit

Permalink
Merge branch 'main' into readme-for-all-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Mar 26, 2024
2 parents 2a8c7bd + 6033938 commit b553e31
Showing 1 changed file with 33 additions and 39 deletions.
72 changes: 33 additions & 39 deletions sdk/log/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"go.opentelemetry.io/otel"
)

func TestNewBatchingProcessorConfiguration(t *testing.T) {
func TestNewBatchingConfig(t *testing.T) {
otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) {
t.Log(err)
}))
Expand All @@ -22,16 +22,15 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
name string
envars map[string]string
options []BatchingOption
want *BatchingProcessor
want batchingConfig
}{
{
name: "Defaults",
want: &BatchingProcessor{
exporter: defaultNoopExporter,
maxQueueSize: dfltMaxQSize,
exportInterval: dfltExpInterval,
exportTimeout: dfltExpTimeout,
exportMaxBatchSize: dfltExpMaxBatchSize,
want: batchingConfig{
maxQSize: newSetting(dfltMaxQSize),
expInterval: newSetting(dfltExpInterval),
expTimeout: newSetting(dfltExpTimeout),
expMaxBatchSize: newSetting(dfltExpMaxBatchSize),
},
},
{
Expand All @@ -42,12 +41,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
WithExportTimeout(time.Hour),
WithExportMaxBatchSize(2),
},
want: &BatchingProcessor{
exporter: defaultNoopExporter,
maxQueueSize: 1,
exportInterval: time.Microsecond,
exportTimeout: time.Hour,
exportMaxBatchSize: 2,
want: batchingConfig{
maxQSize: newSetting(1),
expInterval: newSetting(time.Microsecond),
expTimeout: newSetting(time.Hour),
expMaxBatchSize: newSetting(2),
},
},
{
Expand All @@ -58,12 +56,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
envarExpTimeout: strconv.Itoa(1000),
envarExpMaxBatchSize: strconv.Itoa(10),
},
want: &BatchingProcessor{
exporter: defaultNoopExporter,
maxQueueSize: 1,
exportInterval: 100 * time.Millisecond,
exportTimeout: 1000 * time.Millisecond,
exportMaxBatchSize: 10,
want: batchingConfig{
maxQSize: newSetting(1),
expInterval: newSetting(100 * time.Millisecond),
expTimeout: newSetting(1000 * time.Millisecond),
expMaxBatchSize: newSetting(10),
},
},
{
Expand All @@ -74,12 +71,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
WithExportTimeout(-1 * time.Hour),
WithExportMaxBatchSize(-2),
},
want: &BatchingProcessor{
exporter: defaultNoopExporter,
maxQueueSize: dfltMaxQSize,
exportInterval: dfltExpInterval,
exportTimeout: dfltExpTimeout,
exportMaxBatchSize: dfltExpMaxBatchSize,
want: batchingConfig{
maxQSize: newSetting(dfltMaxQSize),
expInterval: newSetting(dfltExpInterval),
expTimeout: newSetting(dfltExpTimeout),
expMaxBatchSize: newSetting(dfltExpMaxBatchSize),
},
},
{
Expand All @@ -90,12 +86,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
envarExpTimeout: "-1",
envarExpMaxBatchSize: "-1",
},
want: &BatchingProcessor{
exporter: defaultNoopExporter,
maxQueueSize: dfltMaxQSize,
exportInterval: dfltExpInterval,
exportTimeout: dfltExpTimeout,
exportMaxBatchSize: dfltExpMaxBatchSize,
want: batchingConfig{
maxQSize: newSetting(dfltMaxQSize),
expInterval: newSetting(dfltExpInterval),
expTimeout: newSetting(dfltExpTimeout),
expMaxBatchSize: newSetting(dfltExpMaxBatchSize),
},
},
{
Expand All @@ -113,12 +108,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
WithExportTimeout(time.Hour),
WithExportMaxBatchSize(2),
},
want: &BatchingProcessor{
exporter: defaultNoopExporter,
maxQueueSize: 3,
exportInterval: time.Microsecond,
exportTimeout: time.Hour,
exportMaxBatchSize: 2,
want: batchingConfig{
maxQSize: newSetting(3),
expInterval: newSetting(time.Microsecond),
expTimeout: newSetting(time.Hour),
expMaxBatchSize: newSetting(2),
},
},
}
Expand All @@ -128,7 +122,7 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
for key, value := range tc.envars {
t.Setenv(key, value)
}
assert.Equal(t, tc.want, NewBatchingProcessor(nil, tc.options...))
assert.Equal(t, tc.want, newBatchingConfig(tc.options))
})
}
}

0 comments on commit b553e31

Please sign in to comment.