Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / mvdan.cc / gofumpt@v0.0.0-20200802201014-ab5a8192947d / gofumports / internal / telemetry / event / trace.go
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.
4
5 package event
6
7 import (
8         "context"
9 )
10
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
13 // deferred.
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))
18 }
19
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
22 // deferred.
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))
27 }
28
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
31 // deferred.
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))
36 }
37
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))
42 }