mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-04-17 11:46:27 +02:00
Remove the orphaned RegisterSpanProcessor and UnregisterSpanProcessor #1077
This commit is contained in:
parent
0ba595bddb
commit
e17e3caec8
@ -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 `WithSpan` method of the `Tracer` interface.
|
||||||
The functionality this method provided was limited compared to what a user can provide themselves.
|
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)
|
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
|
### Fixed
|
||||||
|
|
||||||
|
@ -135,8 +135,8 @@ func (p *Provider) RegisterSpanProcessor(s SpanProcessor) {
|
|||||||
|
|
||||||
// UnregisterSpanProcessor removes the given SpanProcessor from the list of SpanProcessors
|
// UnregisterSpanProcessor removes the given SpanProcessor from the list of SpanProcessors
|
||||||
func (p *Provider) UnregisterSpanProcessor(s SpanProcessor) {
|
func (p *Provider) UnregisterSpanProcessor(s SpanProcessor) {
|
||||||
mu.Lock()
|
p.mu.Lock()
|
||||||
defer mu.Unlock()
|
defer p.mu.Unlock()
|
||||||
new := make(spanProcessorMap)
|
new := make(spanProcessorMap)
|
||||||
if old, ok := p.spanProcessors.Load().(spanProcessorMap); ok {
|
if old, ok := p.spanProcessors.Load().(spanProcessorMap); ok {
|
||||||
for k, v := range old {
|
for k, v := range old {
|
||||||
|
@ -16,7 +16,6 @@ package trace
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
|
||||||
|
|
||||||
export "go.opentelemetry.io/otel/sdk/export/trace"
|
export "go.opentelemetry.io/otel/sdk/export/trace"
|
||||||
)
|
)
|
||||||
@ -39,43 +38,3 @@ type SpanProcessor interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type spanProcessorMap map[SpanProcessor]*sync.Once
|
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)
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user