You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-05-22 09:35:21 +02:00
Refactor testing of batching config (#5106)
The BatchingProcessor is not expected to ultimately contain configuration fields for queue size or export parameters (see #5093). This will break TestNewBatchingProcessorConfiguration which tests the configuration by evaluating the BatchingProcessor directly. Instead, test the batchingConfig and rename the test to TestNewBatchingConfig to match what is being tested.
This commit is contained in:
+33
-39
@@ -13,7 +13,7 @@ import (
|
|||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewBatchingProcessorConfiguration(t *testing.T) {
|
func TestNewBatchingConfig(t *testing.T) {
|
||||||
otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) {
|
otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) {
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
}))
|
}))
|
||||||
@@ -22,16 +22,15 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
envars map[string]string
|
envars map[string]string
|
||||||
options []BatchingOption
|
options []BatchingOption
|
||||||
want *BatchingProcessor
|
want batchingConfig
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Defaults",
|
name: "Defaults",
|
||||||
want: &BatchingProcessor{
|
want: batchingConfig{
|
||||||
exporter: defaultNoopExporter,
|
maxQSize: newSetting(dfltMaxQSize),
|
||||||
maxQueueSize: dfltMaxQSize,
|
expInterval: newSetting(dfltExpInterval),
|
||||||
exportInterval: dfltExpInterval,
|
expTimeout: newSetting(dfltExpTimeout),
|
||||||
exportTimeout: dfltExpTimeout,
|
expMaxBatchSize: newSetting(dfltExpMaxBatchSize),
|
||||||
exportMaxBatchSize: dfltExpMaxBatchSize,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -42,12 +41,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
|
|||||||
WithExportTimeout(time.Hour),
|
WithExportTimeout(time.Hour),
|
||||||
WithExportMaxBatchSize(2),
|
WithExportMaxBatchSize(2),
|
||||||
},
|
},
|
||||||
want: &BatchingProcessor{
|
want: batchingConfig{
|
||||||
exporter: defaultNoopExporter,
|
maxQSize: newSetting(1),
|
||||||
maxQueueSize: 1,
|
expInterval: newSetting(time.Microsecond),
|
||||||
exportInterval: time.Microsecond,
|
expTimeout: newSetting(time.Hour),
|
||||||
exportTimeout: time.Hour,
|
expMaxBatchSize: newSetting(2),
|
||||||
exportMaxBatchSize: 2,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -58,12 +56,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
|
|||||||
envarExpTimeout: strconv.Itoa(1000),
|
envarExpTimeout: strconv.Itoa(1000),
|
||||||
envarExpMaxBatchSize: strconv.Itoa(10),
|
envarExpMaxBatchSize: strconv.Itoa(10),
|
||||||
},
|
},
|
||||||
want: &BatchingProcessor{
|
want: batchingConfig{
|
||||||
exporter: defaultNoopExporter,
|
maxQSize: newSetting(1),
|
||||||
maxQueueSize: 1,
|
expInterval: newSetting(100 * time.Millisecond),
|
||||||
exportInterval: 100 * time.Millisecond,
|
expTimeout: newSetting(1000 * time.Millisecond),
|
||||||
exportTimeout: 1000 * time.Millisecond,
|
expMaxBatchSize: newSetting(10),
|
||||||
exportMaxBatchSize: 10,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -74,12 +71,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
|
|||||||
WithExportTimeout(-1 * time.Hour),
|
WithExportTimeout(-1 * time.Hour),
|
||||||
WithExportMaxBatchSize(-2),
|
WithExportMaxBatchSize(-2),
|
||||||
},
|
},
|
||||||
want: &BatchingProcessor{
|
want: batchingConfig{
|
||||||
exporter: defaultNoopExporter,
|
maxQSize: newSetting(dfltMaxQSize),
|
||||||
maxQueueSize: dfltMaxQSize,
|
expInterval: newSetting(dfltExpInterval),
|
||||||
exportInterval: dfltExpInterval,
|
expTimeout: newSetting(dfltExpTimeout),
|
||||||
exportTimeout: dfltExpTimeout,
|
expMaxBatchSize: newSetting(dfltExpMaxBatchSize),
|
||||||
exportMaxBatchSize: dfltExpMaxBatchSize,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -90,12 +86,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
|
|||||||
envarExpTimeout: "-1",
|
envarExpTimeout: "-1",
|
||||||
envarExpMaxBatchSize: "-1",
|
envarExpMaxBatchSize: "-1",
|
||||||
},
|
},
|
||||||
want: &BatchingProcessor{
|
want: batchingConfig{
|
||||||
exporter: defaultNoopExporter,
|
maxQSize: newSetting(dfltMaxQSize),
|
||||||
maxQueueSize: dfltMaxQSize,
|
expInterval: newSetting(dfltExpInterval),
|
||||||
exportInterval: dfltExpInterval,
|
expTimeout: newSetting(dfltExpTimeout),
|
||||||
exportTimeout: dfltExpTimeout,
|
expMaxBatchSize: newSetting(dfltExpMaxBatchSize),
|
||||||
exportMaxBatchSize: dfltExpMaxBatchSize,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -113,12 +108,11 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
|
|||||||
WithExportTimeout(time.Hour),
|
WithExportTimeout(time.Hour),
|
||||||
WithExportMaxBatchSize(2),
|
WithExportMaxBatchSize(2),
|
||||||
},
|
},
|
||||||
want: &BatchingProcessor{
|
want: batchingConfig{
|
||||||
exporter: defaultNoopExporter,
|
maxQSize: newSetting(3),
|
||||||
maxQueueSize: 3,
|
expInterval: newSetting(time.Microsecond),
|
||||||
exportInterval: time.Microsecond,
|
expTimeout: newSetting(time.Hour),
|
||||||
exportTimeout: time.Hour,
|
expMaxBatchSize: newSetting(2),
|
||||||
exportMaxBatchSize: 2,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -128,7 +122,7 @@ func TestNewBatchingProcessorConfiguration(t *testing.T) {
|
|||||||
for key, value := range tc.envars {
|
for key, value := range tc.envars {
|
||||||
t.Setenv(key, value)
|
t.Setenv(key, value)
|
||||||
}
|
}
|
||||||
assert.Equal(t, tc.want, NewBatchingProcessor(nil, tc.options...))
|
assert.Equal(t, tc.want, newBatchingConfig(tc.options))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user