You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-06-25 00:16:49 +02:00
Add test to check bsp ignores OnEnd
and ForceFlush
post Shutdown` (#1772)
* Add test to check bsp ignores OnEnd and ForceFlush post shutdown * Add to CHANGELOG * Check for err return value * Stop test execution if there's error with shutting down bsp Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> * Use assert to check there's no error calling bsp.ForceFlush() Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> * Import require * Add error message for assertion on be.len() Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
@ -23,6 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
@ -289,6 +290,31 @@ func TestBatchSpanProcessorShutdown(t *testing.T) {
|
||||
assert.Equal(t, 1, bp.shutdownCount)
|
||||
}
|
||||
|
||||
func TestBatchSpanProcessorPostShutdown(t *testing.T) {
|
||||
tp := basicTracerProvider(t)
|
||||
be := testBatchExporter{}
|
||||
bsp := sdktrace.NewBatchSpanProcessor(&be)
|
||||
|
||||
tp.RegisterSpanProcessor(bsp)
|
||||
tr := tp.Tracer("Normal")
|
||||
|
||||
generateSpan(t, true, tr, testOption{
|
||||
o: []sdktrace.BatchSpanProcessorOption{
|
||||
sdktrace.WithMaxExportBatchSize(50),
|
||||
},
|
||||
genNumSpans: 60,
|
||||
})
|
||||
|
||||
require.NoError(t, bsp.Shutdown(context.Background()), "shutting down BatchSpanProcessor")
|
||||
lenJustAfterShutdown := be.len()
|
||||
|
||||
_, span := tr.Start(context.Background(), "foo")
|
||||
span.End()
|
||||
assert.NoError(t, bsp.ForceFlush(context.Background()), "force flushing BatchSpanProcessor")
|
||||
|
||||
assert.Equal(t, lenJustAfterShutdown, be.len(), "OnEnd and ForceFlush should have no effect after Shutdown")
|
||||
}
|
||||
|
||||
func TestBatchSpanProcessorForceFlushSucceeds(t *testing.T) {
|
||||
te := testBatchExporter{}
|
||||
tp := basicTracerProvider(t)
|
||||
|
Reference in New Issue
Block a user