1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 // StartSpan sends a span start event with the supplied tag list to the exporter.
12 // It also returns a function that will end the span, which should normally be
14 func StartSpan(ctx context.Context, name string, tags ...Tag) (context.Context, func()) {
15 return dispatchPair(ctx,
16 makeEvent(StartSpanType, sTags{Name.Of(name)}, tags),
17 makeEvent(EndSpanType, sTags{}, nil))
20 // StartSpan1 sends a span start event with the supplied tag list to the exporter.
21 // It also returns a function that will end the span, which should normally be
23 func StartSpan1(ctx context.Context, name string, t1 Tag) (context.Context, func()) {
24 return dispatchPair(ctx,
25 makeEvent(StartSpanType, sTags{Name.Of(name), t1}, nil),
26 makeEvent(EndSpanType, sTags{}, nil))
29 // StartSpan2 sends a span start event with the supplied tag list to the exporter.
30 // It also returns a function that will end the span, which should normally be
32 func StartSpan2(ctx context.Context, name string, t1, t2 Tag) (context.Context, func()) {
33 return dispatchPair(ctx,
34 makeEvent(StartSpanType, sTags{Name.Of(name), t1, t2}, nil),
35 makeEvent(EndSpanType, sTags{}, nil))
38 // Detach returns a context without an associated span.
39 // This allows the creation of spans that are not children of the current span.
40 func Detach(ctx context.Context) context.Context {
41 return dispatch(ctx, makeEvent(DetachType, sTags{}, nil))