1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-04-07 07:00:13 +02:00

Merge pull request #1079 from TMeireOqton/remove-orphaned-spanprocessor-funcs

Remove the orphaned RegisterSpanProcessor and UnregisterSpanProcessor
This commit is contained in:
Anthony Mirabella 2020-08-24 17:53:20 -04:00 committed by GitHub
commit cd1a868dde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 43 deletions

View File

@ -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

View File

@ -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 {

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)
}