diff --git a/CHANGELOG.md b/CHANGELOG.md index 79b78076f..d3a41eb09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `WithSpan` method of the `Tracer` interface. The functionality this method provided was limited compared to what a user can provide themselves. It was removed with the understanding that if there is sufficient user need it can be added back based on actual user usage. (#1043) +- The `RegisterSpanProcessor` and `UnregisterSpanProcessor` functions. + These were holdovers from an approach prior to the TracerProvider design. They were not used anymore. (#1077) ### Fixed diff --git a/sdk/trace/provider.go b/sdk/trace/provider.go index 2e367a1cd..82a67e2cc 100644 --- a/sdk/trace/provider.go +++ b/sdk/trace/provider.go @@ -135,8 +135,8 @@ func (p *Provider) RegisterSpanProcessor(s SpanProcessor) { // UnregisterSpanProcessor removes the given SpanProcessor from the list of SpanProcessors func (p *Provider) UnregisterSpanProcessor(s SpanProcessor) { - mu.Lock() - defer mu.Unlock() + p.mu.Lock() + defer p.mu.Unlock() new := make(spanProcessorMap) if old, ok := p.spanProcessors.Load().(spanProcessorMap); ok { for k, v := range old { diff --git a/sdk/trace/span_processor.go b/sdk/trace/span_processor.go index 40c9fa386..efe3eb2bd 100644 --- a/sdk/trace/span_processor.go +++ b/sdk/trace/span_processor.go @@ -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) -}