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:
@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- Adds test to check BatchSpanProcessor ignores `OnEnd` and `ForceFlush` post `Shutdown`. (#1772)
|
||||||
- Option `ExportTimeout` was added to batch span processor. (#1755)
|
- Option `ExportTimeout` was added to batch span processor. (#1755)
|
||||||
- Adds semantic conventions for exceptions. (#1492)
|
- Adds semantic conventions for exceptions. (#1492)
|
||||||
- Added support for configuring OTLP/HTTP Endpoints, Headers, Compression and Timeout via the Environment Variables. (#1758)
|
- Added support for configuring OTLP/HTTP Endpoints, Headers, Compression and Timeout via the Environment Variables. (#1758)
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
|
||||||
@ -289,6 +290,31 @@ func TestBatchSpanProcessorShutdown(t *testing.T) {
|
|||||||
assert.Equal(t, 1, bp.shutdownCount)
|
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) {
|
func TestBatchSpanProcessorForceFlushSucceeds(t *testing.T) {
|
||||||
te := testBatchExporter{}
|
te := testBatchExporter{}
|
||||||
tp := basicTracerProvider(t)
|
tp := basicTracerProvider(t)
|
||||||
|
Reference in New Issue
Block a user