GoPLS Viewer

Home|gopls/internal/event/core/fast.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
5package core
6
7import (
8    "context"
9
10    "golang.org/x/tools/internal/event/keys"
11    "golang.org/x/tools/internal/event/label"
12)
13
14// Log1 takes a message and one label delivers a log event to the exporter.
15// It is a customized version of Print that is faster and does no allocation.
16func Log1(ctx context.Contextmessage stringt1 label.Label) {
17    Export(ctxMakeEvent([3]label.Label{
18        keys.Msg.Of(message),
19        t1,
20    }, nil))
21}
22
23// Log2 takes a message and two labels and delivers a log event to the exporter.
24// It is a customized version of Print that is faster and does no allocation.
25func Log2(ctx context.Contextmessage stringt1 label.Labelt2 label.Label) {
26    Export(ctxMakeEvent([3]label.Label{
27        keys.Msg.Of(message),
28        t1,
29        t2,
30    }, nil))
31}
32
33// Metric1 sends a label event to the exporter with the supplied labels.
34func Metric1(ctx context.Contextt1 label.Labelcontext.Context {
35    return Export(ctxMakeEvent([3]label.Label{
36        keys.Metric.New(),
37        t1,
38    }, nil))
39}
40
41// Metric2 sends a label event to the exporter with the supplied labels.
42func Metric2(ctx context.Contextt1t2 label.Labelcontext.Context {
43    return Export(ctxMakeEvent([3]label.Label{
44        keys.Metric.New(),
45        t1,
46        t2,
47    }, nil))
48}
49
50// Start1 sends a span start event with the supplied label list to the exporter.
51// It also returns a function that will end the span, which should normally be
52// deferred.
53func Start1(ctx context.Contextname stringt1 label.Label) (context.Context, func()) {
54    return ExportPair(ctx,
55        MakeEvent([3]label.Label{
56            keys.Start.Of(name),
57            t1,
58        }, nil),
59        MakeEvent([3]label.Label{
60            keys.End.New(),
61        }, nil))
62}
63
64// Start2 sends a span start event with the supplied label list to the exporter.
65// It also returns a function that will end the span, which should normally be
66// deferred.
67func Start2(ctx context.Contextname stringt1t2 label.Label) (context.Context, func()) {
68    return ExportPair(ctx,
69        MakeEvent([3]label.Label{
70            keys.Start.Of(name),
71            t1,
72            t2,
73        }, nil),
74        MakeEvent([3]label.Label{
75            keys.End.New(),
76        }, nil))
77}
78
MembersX
Metric1.t1
Start1
Start1.t1
Start2.t2
Log2
Metric2
Start1.ctx
Start2.t1
Log2.t1
Metric1
Metric2.ctx
Metric2.t2
Log1
Log1.message
Log1.t1
Log2.ctx
Start2
Start2.ctx
Metric1.ctx
Metric2.t1
Start1.name
Start2.name
keys
Log1.ctx
Log2.message
Log2.t2
Members
X