diff --git a/tracer/tracer.go b/tracer/tracer.go index 45c20df5..726a5c3d 100644 --- a/tracer/tracer.go +++ b/tracer/tracer.go @@ -29,10 +29,10 @@ type ContextAttrFunc func(ctx context.Context) []interface{} func init() { logger.DefaultContextAttrFuncs = append(logger.DefaultContextAttrFuncs, func(ctx context.Context) []interface{} { - if span, ok := SpanFromContext(ctx); ok { + if sp, ok := SpanFromContext(ctx); ok && sp != nil && sp.IsRecording() { return []interface{}{ - TraceIDKey, span.TraceID(), - SpanIDKey, span.SpanID(), + TraceIDKey, sp.TraceID(), + SpanIDKey, sp.SpanID(), } } return nil