1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-03-17 20:57:51 +02:00

Remove flaky BatchSpanProcessor.ForceFlush() test (#1189)

It is unreliable with no clear good way to make it reliable.  The
ForceFlush() method is a simple passthrough to bsp.exportSpans() and the
existing tests of that method should suffice.

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
Anthony Mirabella 2020-09-21 16:30:49 -04:00 committed by GitHub
parent fa741472e7
commit b9357d7ee2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,53 +181,6 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
}
}
func TestBatchSpanProcessorForceFlush(t *testing.T) {
option := testOption{
name: "ForceFlush()",
o: []sdktrace.BatchSpanProcessorOption{
sdktrace.WithBatchTimeout(10 * time.Second),
sdktrace.WithMaxQueueSize(2000),
sdktrace.WithMaxExportBatchSize(2000),
},
wantNumSpans: 205,
wantBatchCount: 1,
genNumSpans: 205,
}
te := testBatchExporter{}
tp := basicProvider(t)
ssp := createAndRegisterBatchSP(option, &te)
if ssp == nil {
t.Fatalf("%s: Error creating new instance of BatchSpanProcessor\n", option.name)
}
tp.RegisterSpanProcessor(ssp)
tr := tp.Tracer("BatchSpanProcessorWithOptions")
generateSpan(t, false, tr, option)
ssp.ForceFlush()
gotNumOfSpans := te.len()
if 0 == gotNumOfSpans {
t.Errorf("number of flushed spans is zero")
}
tp.UnregisterSpanProcessor(ssp)
gotNumOfSpans = te.len()
if option.wantNumSpans != gotNumOfSpans {
t.Errorf("number of exported span: got %+v, want %+v\n",
gotNumOfSpans, option.wantNumSpans)
}
gotBatchCount := te.getBatchCount()
if gotBatchCount < option.wantBatchCount {
t.Errorf("number batches: got %+v, want >= %+v\n",
gotBatchCount, option.wantBatchCount)
t.Errorf("Batches %v\n", te.sizes)
}
}
func createAndRegisterBatchSP(option testOption, te *testBatchExporter) *sdktrace.BatchSpanProcessor {
// Always use blocking queue to avoid flaky tests.
options := append(option.o, sdktrace.WithBlocking())