1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-12-01 23:12:29 +02:00

Register/unregister in the fixed order (#1198)

- change the processors' map to array
- increase test coverage

Signed-off-by: Hui Kang <kangh@us.ibm.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
huikang
2020-09-24 14:43:23 -04:00
committed by GitHub
parent 559fecd73e
commit b97533a74b
6 changed files with 82 additions and 41 deletions

View File

@@ -139,8 +139,8 @@ func (s *span) End(options ...apitrace.SpanOption) {
}
config := apitrace.NewSpanConfig(options...)
s.endOnce.Do(func() {
sps, _ := s.tracer.provider.spanProcessors.Load().(spanProcessorMap)
mustExportOrProcess := len(sps) > 0
sps, ok := s.tracer.provider.spanProcessors.Load().(spanProcessorStates)
mustExportOrProcess := ok && len(sps) > 0
if mustExportOrProcess {
sd := s.makeSpanData()
if config.Timestamp.IsZero() {
@@ -148,8 +148,8 @@ func (s *span) End(options ...apitrace.SpanOption) {
} else {
sd.EndTime = config.Timestamp
}
for sp := range sps {
sp.OnEnd(sd)
for _, sp := range sps {
sp.sp.OnEnd(sd)
}
}
})