fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Simplify trace methods (#942)

Small refactor to simplify the logic in `trace.New`. It inlines a couple public
methods that don't need to be exposed separately.

+4 -27
-11
internal/trace/opentracing.go
··· 36 36 } 37 37 return tracer 38 38 } 39 - 40 - // StartSpanFromContext starts a span using the tracer returned by invoking GetOpenTracer with the 41 - // passed-in tracer. 42 - func StartSpanFromContextWithTracer(ctx context.Context, tracer opentracing.Tracer, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context) { 43 - return opentracing.StartSpanFromContextWithTracer(ctx, GetOpenTracer(ctx, tracer), operationName, opts...) 44 - } 45 - 46 - // StartSpanFromContext starts a span using the tracer returned by GetOpenTracer. 47 - func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context) { 48 - return StartSpanFromContextWithTracer(ctx, GetOpenTracer(ctx, nil), operationName, opts...) 49 - }
+4 -16
internal/trace/trace.go
··· 17 17 nettrace "golang.org/x/net/trace" 18 18 ) 19 19 20 - // A Tracer for trace creation, parameterised over an 21 - // opentracing.Tracer. Use this if you don't want to use 22 - // the global tracer. 23 - type Tracer struct { 24 - Tracer opentracing.Tracer 25 - } 26 - 27 20 func New(ctx context.Context, family, title string) (*Trace, context.Context) { 28 - tr := Tracer{Tracer: GetOpenTracer(ctx, nil)} 29 - return tr.New(ctx, family, title) 30 - } 31 - 32 - // New returns a new Trace with the specified family and title. 33 - func (t Tracer) New(ctx context.Context, family, title string) (*Trace, context.Context) { 34 - span, ctx := StartSpanFromContextWithTracer( 35 - ctx, 36 - t.Tracer, 21 + tracer := GetOpenTracer(ctx, nil) 22 + span, ctx := opentracing.StartSpanFromContextWithTracer(ctx, 23 + tracer, 37 24 family, 38 25 opentracing.Tag{Key: "title", Value: title}, 39 26 ) 27 + 40 28 tr := nettrace.New(family, title) 41 29 trace := &Trace{span: span, trace: tr, family: family} 42 30 if parent := TraceFromContext(ctx); parent != nil {