1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-27 22:49:15 +02:00

SDK: Multiple Unregister should not trigger multiple shutdown call (#176)

* SDK: Multiple Unregister should not trigger multiple shutdown call

* fix a data race: waitGroup.Add() should be outside of a goroutine
This commit is contained in:
Artem Kartasov
2019-10-09 13:31:29 +07:00
committed by rghetia
parent be8fb0b4e2
commit ffbef6a007
3 changed files with 12 additions and 9 deletions

View File

@@ -117,7 +117,7 @@ func TestSpanProcessorShutdown(t *testing.T) {
t.Fatalf("Error creating new instance of TestSpanProcessor\n")
}
wantCount := sp.shutdownCount + 1
wantCount := 1
sp.Shutdown()
gotCount := sp.shutdownCount
@@ -127,13 +127,13 @@ func TestSpanProcessorShutdown(t *testing.T) {
}
func TestMultipleUnregisterSpanProcessorCalls(t *testing.T) {
name := "Increment shutdown counter after each UnregisterSpanProcessor call"
name := "Increment shutdown counter after first UnregisterSpanProcessor call"
sp := NewTestSpanProcessor()
if sp == nil {
t.Fatalf("Error creating new instance of TestSpanProcessor\n")
}
wantCount := sp.shutdownCount + 1
wantCount := 1
sdktrace.RegisterSpanProcessor(sp)
sdktrace.UnregisterSpanProcessor(sp)
@@ -143,8 +143,7 @@ func TestMultipleUnregisterSpanProcessorCalls(t *testing.T) {
t.Errorf("%s: wrong counter: got %d, want %d\n", name, gotCount, wantCount)
}
// Multiple UnregisterSpanProcessor triggers multiple Shutdown calls.
wantCount = wantCount + 1
// Multiple UnregisterSpanProcessor should not trigger multiple Shutdown calls.
sdktrace.UnregisterSpanProcessor(sp)
gotCount = sp.shutdownCount