mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-02-07 13:31:42 +02:00
Performance improvement: avoid creating multiple same read-only objects (#2104)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
parent
ab78dbd05b
commit
9b1a5f7001
@ -262,11 +262,13 @@ func (s *span) End(options ...trace.SpanEndOption) {
|
|||||||
}
|
}
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
|
||||||
sps, ok := s.tracer.provider.spanProcessors.Load().(spanProcessorStates)
|
if sps, ok := s.tracer.provider.spanProcessors.Load().(spanProcessorStates); ok {
|
||||||
mustExportOrProcess := ok && len(sps) > 0
|
if len(sps) == 0 {
|
||||||
if mustExportOrProcess {
|
return
|
||||||
|
}
|
||||||
|
snap := s.snapshot()
|
||||||
for _, sp := range sps {
|
for _, sp := range sps {
|
||||||
sp.sp.OnEnd(s.snapshot())
|
sp.sp.OnEnd(snap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user