// JoinOrNew creates a new Span joined to the provided DelegatingCarrier or // creates Span from the given tracer. func JoinOrNew(tr opentracing.Tracer, carrier *Span, opName string) (opentracing.Span, error) { if carrier != nil { wireContext, err := tr.Extract(basictracer.Delegator, carrier) switch err { case nil: sp := tr.StartSpan(opName, opentracing.FollowsFrom(wireContext)) sp.LogEvent(opName) return sp, nil case opentracing.ErrSpanContextNotFound: default: return nil, err } } return tr.StartSpan(opName), nil }
// JoinOrNew creates a new Span joined to the provided DelegatingCarrier or // creates Span from the given tracer. func JoinOrNew( tr opentracing.Tracer, carrier *SpanContextCarrier, opName string, ) (opentracing.Span, error) { if carrier != nil { wireContext, err := tr.Extract(basictracer.Delegator, carrier) switch err { case nil: sp := tr.StartSpan(opName, opentracing.FollowsFrom(wireContext)) // Copy baggage items to tags so they show up in the Lightstep UI. sp.Context().ForeachBaggageItem(func(k, v string) bool { sp.SetTag(k, v); return true }) sp.LogFields(otlog.String("event", opName)) return sp, nil case opentracing.ErrSpanContextNotFound: default: return nil, err } } return tr.StartSpan(opName), nil }