From a64b86bad0ae294f4bc143a001378d4549ae206d Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Thu, 6 Jul 2017 11:10:32 -0400 Subject: [PATCH] tracing: start net/trace span in ChildSpan Fixes #16881. --- pkg/util/tracing/tracer.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/util/tracing/tracer.go b/pkg/util/tracing/tracer.go index d4ae69eb5ed2..e332342c048c 100644 --- a/pkg/util/tracing/tracer.go +++ b/pkg/util/tracing/tracer.go @@ -335,13 +335,6 @@ func StartChildSpan( linkShadowSpan(s, pSpan.shadowTr, pSpan.shadowSpan.Context(), opentracing.ChildOfRef) } - if pSpan.netTr != nil || pSpan.shadowTr != nil { - // Copy baggage items to tags so they show up in the shadow tracer UI or x/net/trace. - for k, v := range s.mu.Baggage { - s.SetTag(k, v) - } - } - // Start recording if necessary. if pSpan.isRecording() { recordingGroup := pSpan.mu.recordingGroup @@ -351,6 +344,18 @@ func StartChildSpan( s.enableRecording(recordingGroup, pSpan.mu.recordingType) } + if pSpan.netTr != nil { + s.netTr = trace.New("tracing", operationName) + s.netTr.SetMaxEvents(maxLogsPerSpan) + } + + if pSpan.netTr != nil || pSpan.shadowTr != nil { + // Copy baggage items to tags so they show up in the shadow tracer UI or x/net/trace. + for k, v := range s.mu.Baggage { + s.SetTag(k, v) + } + } + pSpan.mu.Unlock() return s }