You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-12-01 23:12:29 +02:00
sdk/trace: do not defer if not self-observing (#7206)
Allow branch prediction to help avoid tail function call instead of the other way around.
This commit is contained in:
@@ -497,8 +497,8 @@ func (s *recordingSpan) End(options ...trace.SpanEndOption) {
|
||||
}
|
||||
s.mu.Unlock()
|
||||
|
||||
defer func() {
|
||||
if s.tracer.selfObservabilityEnabled {
|
||||
if s.tracer.selfObservabilityEnabled {
|
||||
defer func() {
|
||||
// Determine the sampling result and create the corresponding attribute.
|
||||
var attrSamplingResult attribute.KeyValue
|
||||
if s.spanContext.IsSampled() {
|
||||
@@ -510,8 +510,8 @@ func (s *recordingSpan) End(options ...trace.SpanEndOption) {
|
||||
}
|
||||
|
||||
s.tracer.spanLiveMetric.Add(context.Background(), -1, attrSamplingResult)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
}
|
||||
|
||||
sps := s.tracer.provider.getSpanProcessors()
|
||||
if len(sps) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user