1
0
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:
Tyler Yahn
2025-08-18 01:25:36 -07:00
committed by GitHub
parent cac7421c19
commit 9488493043

View File

@@ -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 {