Skip to content

Commit

Permalink
Performance improvement: avoid creating multiple same read-only objec…
Browse files Browse the repository at this point in the history
…ts (open-telemetry#2104)

Signed-off-by: Bogdan Drutu <[email protected]>

Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
bogdandrutu and MrAlias authored Jul 20, 2021
1 parent ab78dbd commit 9b1a5f7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sdk/trace/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,13 @@ func (s *span) End(options ...trace.SpanEndOption) {
}
s.mu.Unlock()

sps, ok := s.tracer.provider.spanProcessors.Load().(spanProcessorStates)
mustExportOrProcess := ok && len(sps) > 0
if mustExportOrProcess {
if sps, ok := s.tracer.provider.spanProcessors.Load().(spanProcessorStates); ok {
if len(sps) == 0 {
return
}
snap := s.snapshot()
for _, sp := range sps {
sp.sp.OnEnd(s.snapshot())
sp.sp.OnEnd(snap)
}
}
}
Expand Down

0 comments on commit 9b1a5f7

Please sign in to comment.