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

Remove the orphaned RegisterSpanProcessor and UnregisterSpanProcessor #1077

This commit is contained in:
Thomas Meire
2020-08-22 09:38:52 +02:00
parent 0ba595bddb
commit e17e3caec8
3 changed files with 4 additions and 43 deletions

View File

@ -16,7 +16,6 @@ package trace
import (
"sync"
"sync/atomic"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
@ -39,43 +38,3 @@ type SpanProcessor interface {
}
type spanProcessorMap map[SpanProcessor]*sync.Once
var (
mu sync.Mutex
spanProcessors atomic.Value
)
// RegisterSpanProcessor adds to the list of SpanProcessors that will receive sampled
// trace spans.
func RegisterSpanProcessor(e SpanProcessor) {
mu.Lock()
defer mu.Unlock()
new := make(spanProcessorMap)
if old, ok := spanProcessors.Load().(spanProcessorMap); ok {
for k, v := range old {
new[k] = v
}
}
new[e] = &sync.Once{}
spanProcessors.Store(new)
}
// UnregisterSpanProcessor removes from the list of SpanProcessors the SpanProcessor that was
// registered with the given name.
func UnregisterSpanProcessor(s SpanProcessor) {
mu.Lock()
defer mu.Unlock()
new := make(spanProcessorMap)
if old, ok := spanProcessors.Load().(spanProcessorMap); ok {
for k, v := range old {
new[k] = v
}
}
if stopOnce, ok := new[s]; ok && stopOnce != nil {
stopOnce.Do(func() {
s.Shutdown()
})
}
delete(new, s)
spanProcessors.Store(new)
}