Skip to content

Commit

Permalink
Update tracer to guard for a nil ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
wildefires authored Aug 25, 2022
1 parent 8423364 commit 1d2a936
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sdk/trace/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ var _ trace.Tracer = &tracer{}
func (tr *tracer) Start(ctx context.Context, name string, options ...trace.SpanStartOption) (context.Context, trace.Span) {
config := trace.NewSpanStartConfig(options...)

// If ctx is nil, set to context.Background() as context.WithValue will panic on a nil value.
if ctx == nil {
ctx = context.Background()
}

// For local spans created by this SDK, track child span count.
if p := trace.SpanFromContext(ctx); p != nil {
if sdkSpan, ok := p.(*recordingSpan); ok {
Expand Down

0 comments on commit 1d2a936

Please sign in to comment.