You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-15 01:04:25 +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:
@ -38,7 +38,7 @@ type SpanProcessor interface {
|
||||
Shutdown()
|
||||
}
|
||||
|
||||
type spanProcessorMap map[SpanProcessor]struct{}
|
||||
type spanProcessorMap map[SpanProcessor]*sync.Once
|
||||
|
||||
var (
|
||||
mu sync.Mutex
|
||||
@ -56,7 +56,7 @@ func RegisterSpanProcessor(e SpanProcessor) {
|
||||
new[k] = v
|
||||
}
|
||||
}
|
||||
new[e] = struct{}{}
|
||||
new[e] = &sync.Once{}
|
||||
spanProcessors.Store(new)
|
||||
}
|
||||
|
||||
@ -71,7 +71,11 @@ func UnregisterSpanProcessor(s SpanProcessor) {
|
||||
new[k] = v
|
||||
}
|
||||
}
|
||||
if stopOnce, ok := new[s]; ok && stopOnce != nil {
|
||||
stopOnce.Do(func() {
|
||||
s.Shutdown()
|
||||
})
|
||||
}
|
||||
delete(new, s)
|
||||
spanProcessors.Store(new)
|
||||
s.Shutdown()
|
||||
}
|
||||
|
Reference in New Issue
Block a user