Skip to content

Commit

Permalink
Remove the orphaned RegisterSpanProcessor and UnregisterSpanProcessor #…
Browse files Browse the repository at this point in the history
  • Loading branch information
TMeireOqton committed Aug 22, 2020
1 parent 0ba595b commit e17e3ca
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 43 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions sdk/trace/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
41 changes: 0 additions & 41 deletions sdk/trace/span_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package trace

import (
"sync"
"sync/atomic"

export "go.opentelemetry.io/otel/sdk/export/trace"
)
Expand All @@ -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)
}

0 comments on commit e17e3ca

Please sign in to comment.