internal/telemetry: renaming to internal/event
internal/telemetry/event was renamed to internal/event/core
Some things were partly moved from internal/telemetry/event straight to
internal/event to minimize churn in the following restructuring.
Change-Id: I8511241c68d2d05f64c52dbe04748086dd325158
Reviewed-on: https://go-review.googlesource.com/c/tools/+/229237
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/internal/telemetry/bench_test.go b/internal/event/bench_test.go
similarity index 76%
rename from internal/telemetry/bench_test.go
rename to internal/event/bench_test.go
index df0f1ea..f4fc727 100644
--- a/internal/telemetry/bench_test.go
+++ b/internal/event/bench_test.go
@@ -1,4 +1,4 @@
-package telemetry_test
+package event_test
import (
"context"
@@ -6,8 +6,9 @@
"log"
"testing"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export"
)
type Hooks struct {
@@ -16,12 +17,12 @@
}
var (
- aValue = event.NewIntKey("a", "")
- bValue = event.NewStringKey("b", "")
- aCount = event.NewInt64Key("aCount", "Count of time A is called.")
- aStat = event.NewIntKey("aValue", "A value.")
- bCount = event.NewInt64Key("B", "Count of time B is called.")
- bLength = event.NewIntKey("BLen", "B length.")
+ aValue = core.NewIntKey("a", "")
+ bValue = core.NewStringKey("b", "")
+ aCount = core.NewInt64Key("aCount", "Count of time A is called.")
+ aStat = core.NewIntKey("aValue", "A value.")
+ bCount = core.NewInt64Key("B", "Count of time B is called.")
+ bLength = core.NewIntKey("BLen", "B length.")
Baseline = Hooks{
A: func(ctx context.Context, a int) (context.Context, func()) {
@@ -45,33 +46,33 @@
Log = Hooks{
A: func(ctx context.Context, a int) (context.Context, func()) {
- event.Print1(ctx, "A", aValue.Of(a))
+ core.Print1(ctx, "A", aValue.Of(a))
return ctx, func() {}
},
B: func(ctx context.Context, b string) (context.Context, func()) {
- event.Print1(ctx, "B", bValue.Of(b))
+ core.Print1(ctx, "B", bValue.Of(b))
return ctx, func() {}
},
}
Trace = Hooks{
A: func(ctx context.Context, a int) (context.Context, func()) {
- return event.StartSpan1(ctx, "A", aValue.Of(a))
+ return core.StartSpan1(ctx, "A", aValue.Of(a))
},
B: func(ctx context.Context, b string) (context.Context, func()) {
- return event.StartSpan1(ctx, "B", bValue.Of(b))
+ return core.StartSpan1(ctx, "B", bValue.Of(b))
},
}
Stats = Hooks{
A: func(ctx context.Context, a int) (context.Context, func()) {
- event.Record1(ctx, aStat.Of(a))
- event.Record1(ctx, aCount.Of(1))
+ core.Record1(ctx, aStat.Of(a))
+ core.Record1(ctx, aCount.Of(1))
return ctx, func() {}
},
B: func(ctx context.Context, b string) (context.Context, func()) {
- event.Record1(ctx, bLength.Of(len(b)))
- event.Record1(ctx, bCount.Of(1))
+ core.Record1(ctx, bLength.Of(len(b)))
+ core.Record1(ctx, bCount.Of(1))
return ctx, func() {}
},
}
@@ -146,6 +147,6 @@
log.SetOutput(ioutil.Discard)
}
-func noopExporter(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+func noopExporter(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
return ctx
}
diff --git a/internal/telemetry/event/event.go b/internal/event/core/event.go
similarity index 97%
rename from internal/telemetry/event/event.go
rename to internal/event/core/event.go
index 2b990c5..ef72764 100644
--- a/internal/telemetry/event/event.go
+++ b/internal/event/core/event.go
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package event provides support for event based telemetry.
-package event
+// Package core provides support for event based telemetry.
+package core
import (
"fmt"
diff --git a/internal/telemetry/event/export.go b/internal/event/core/export.go
similarity index 98%
rename from internal/telemetry/event/export.go
rename to internal/event/core/export.go
index a2633b6..e4a9141 100644
--- a/internal/telemetry/event/export.go
+++ b/internal/event/core/export.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package event
+package core
import (
"context"
diff --git a/internal/telemetry/event/key.go b/internal/event/core/key.go
similarity index 99%
rename from internal/telemetry/event/key.go
rename to internal/event/core/key.go
index acde751..6c28fb2 100644
--- a/internal/telemetry/event/key.go
+++ b/internal/event/core/key.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package event
+package core
import (
"fmt"
diff --git a/internal/telemetry/event/label.go b/internal/event/core/label.go
similarity index 98%
rename from internal/telemetry/event/label.go
rename to internal/event/core/label.go
index edd34bb..45725e7 100644
--- a/internal/telemetry/event/label.go
+++ b/internal/event/core/label.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package event
+package core
import (
"context"
diff --git a/internal/telemetry/event/log.go b/internal/event/core/log.go
similarity index 99%
rename from internal/telemetry/event/log.go
rename to internal/event/core/log.go
index 8d0a046..a6bdac8 100644
--- a/internal/telemetry/event/log.go
+++ b/internal/event/core/log.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package event
+package core
import (
"context"
diff --git a/internal/telemetry/event/metric.go b/internal/event/core/metric.go
similarity index 98%
rename from internal/telemetry/event/metric.go
rename to internal/event/core/metric.go
index e4092bb..c75f79b 100644
--- a/internal/telemetry/event/metric.go
+++ b/internal/event/core/metric.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package event
+package core
import (
"context"
diff --git a/internal/telemetry/event/tag.go b/internal/event/core/tag.go
similarity index 99%
rename from internal/telemetry/event/tag.go
rename to internal/event/core/tag.go
index 5230736..57de6ba 100644
--- a/internal/telemetry/event/tag.go
+++ b/internal/event/core/tag.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package event
+package core
import (
"fmt"
diff --git a/internal/telemetry/event/tag_test.go b/internal/event/core/tag_test.go
similarity index 60%
rename from internal/telemetry/event/tag_test.go
rename to internal/event/core/tag_test.go
index 3d0832e..c03b146 100644
--- a/internal/telemetry/event/tag_test.go
+++ b/internal/event/core/tag_test.go
@@ -2,76 +2,76 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package event_test
+package core_test
import (
"bytes"
"fmt"
"testing"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event/core"
)
var (
- AKey = event.NewStringKey("A", "")
- BKey = event.NewStringKey("B", "")
- CKey = event.NewStringKey("C", "")
+ AKey = core.NewStringKey("A", "")
+ BKey = core.NewStringKey("B", "")
+ CKey = core.NewStringKey("C", "")
A = AKey.Of("a")
B = BKey.Of("b")
C = CKey.Of("c")
- all = []event.Tag{A, B, C}
+ all = []core.Tag{A, B, C}
)
func TestTagList(t *testing.T) {
for _, test := range []struct {
name string
- tags []event.Tag
+ tags []core.Tag
expect string
}{{
name: "empty",
}, {
name: "single",
- tags: []event.Tag{A},
+ tags: []core.Tag{A},
expect: `A="a"`,
}, {
name: "invalid",
- tags: []event.Tag{{}},
+ tags: []core.Tag{{}},
expect: ``,
}, {
name: "two",
- tags: []event.Tag{A, B},
+ tags: []core.Tag{A, B},
expect: `A="a", B="b"`,
}, {
name: "three",
- tags: []event.Tag{A, B, C},
+ tags: []core.Tag{A, B, C},
expect: `A="a", B="b", C="c"`,
}, {
name: "missing A",
- tags: []event.Tag{{}, B, C},
+ tags: []core.Tag{{}, B, C},
expect: `B="b", C="c"`,
}, {
name: "missing B",
- tags: []event.Tag{A, {}, C},
+ tags: []core.Tag{A, {}, C},
expect: `A="a", C="c"`,
}, {
name: "missing C",
- tags: []event.Tag{A, B, {}},
+ tags: []core.Tag{A, B, {}},
expect: `A="a", B="b"`,
}, {
name: "missing AB",
- tags: []event.Tag{{}, {}, C},
+ tags: []core.Tag{{}, {}, C},
expect: `C="c"`,
}, {
name: "missing AC",
- tags: []event.Tag{{}, B, {}},
+ tags: []core.Tag{{}, B, {}},
expect: `B="b"`,
}, {
name: "missing BC",
- tags: []event.Tag{A, {}, {}},
+ tags: []core.Tag{A, {}, {}},
expect: `A="a"`,
}} {
t.Run(test.name, func(t *testing.T) {
- got := printList(event.NewTagList(test.tags...))
+ got := printList(core.NewTagList(test.tags...))
if got != test.expect {
t.Errorf("got %q want %q", got, test.expect)
}
@@ -82,8 +82,8 @@
func TestTagFilter(t *testing.T) {
for _, test := range []struct {
name string
- tags []event.Tag
- filters []event.Key
+ tags []core.Tag
+ filters []core.Key
expect string
}{{
name: "no filters",
@@ -91,32 +91,32 @@
expect: `A="a", B="b", C="c"`,
}, {
name: "no tags",
- filters: []event.Key{AKey},
+ filters: []core.Key{AKey},
expect: ``,
}, {
name: "filter A",
tags: all,
- filters: []event.Key{AKey},
+ filters: []core.Key{AKey},
expect: `B="b", C="c"`,
}, {
name: "filter B",
tags: all,
- filters: []event.Key{BKey},
+ filters: []core.Key{BKey},
expect: `A="a", C="c"`,
}, {
name: "filter C",
tags: all,
- filters: []event.Key{CKey},
+ filters: []core.Key{CKey},
expect: `A="a", B="b"`,
}, {
name: "filter AC",
tags: all,
- filters: []event.Key{AKey, CKey},
+ filters: []core.Key{AKey, CKey},
expect: `B="b"`,
}} {
t.Run(test.name, func(t *testing.T) {
- tags := event.NewTagList(test.tags...)
- got := printList(event.Filter(tags, test.filters...))
+ tags := core.NewTagList(test.tags...)
+ got := printList(core.Filter(tags, test.filters...))
if got != test.expect {
t.Errorf("got %q want %q", got, test.expect)
}
@@ -127,51 +127,51 @@
func TestTagMap(t *testing.T) {
for _, test := range []struct {
name string
- tags []event.Tag
- keys []event.Key
+ tags []core.Tag
+ keys []core.Key
expect string
}{{
name: "no tags",
- keys: []event.Key{AKey},
+ keys: []core.Key{AKey},
expect: `nil`,
}, {
name: "match A",
tags: all,
- keys: []event.Key{AKey},
+ keys: []core.Key{AKey},
expect: `A="a"`,
}, {
name: "match B",
tags: all,
- keys: []event.Key{BKey},
+ keys: []core.Key{BKey},
expect: `B="b"`,
}, {
name: "match C",
tags: all,
- keys: []event.Key{CKey},
+ keys: []core.Key{CKey},
expect: `C="c"`,
}, {
name: "match ABC",
tags: all,
- keys: []event.Key{AKey, BKey, CKey},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `A="a", B="b", C="c"`,
}, {
name: "missing A",
- tags: []event.Tag{{}, B, C},
- keys: []event.Key{AKey, BKey, CKey},
+ tags: []core.Tag{{}, B, C},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `nil, B="b", C="c"`,
}, {
name: "missing B",
- tags: []event.Tag{A, {}, C},
- keys: []event.Key{AKey, BKey, CKey},
+ tags: []core.Tag{A, {}, C},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `A="a", nil, C="c"`,
}, {
name: "missing C",
- tags: []event.Tag{A, B, {}},
- keys: []event.Key{AKey, BKey, CKey},
+ tags: []core.Tag{A, B, {}},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `A="a", B="b", nil`,
}} {
t.Run(test.name, func(t *testing.T) {
- tagMap := event.NewTagMap(test.tags...)
+ tagMap := core.NewTagMap(test.tags...)
got := printTagMap(tagMap, test.keys)
if got != test.expect {
t.Errorf("got %q want %q", got, test.expect)
@@ -183,56 +183,56 @@
func TestTagMapMerge(t *testing.T) {
for _, test := range []struct {
name string
- maps []event.TagMap
- keys []event.Key
+ maps []core.TagMap
+ keys []core.Key
expect string
}{{
name: "no maps",
- keys: []event.Key{AKey},
+ keys: []core.Key{AKey},
expect: `nil`,
}, {
name: "one map",
- maps: []event.TagMap{event.NewTagMap(all...)},
- keys: []event.Key{AKey},
+ maps: []core.TagMap{core.NewTagMap(all...)},
+ keys: []core.Key{AKey},
expect: `A="a"`,
}, {
name: "invalid map",
- maps: []event.TagMap{event.NewTagMap()},
- keys: []event.Key{AKey},
+ maps: []core.TagMap{core.NewTagMap()},
+ keys: []core.Key{AKey},
expect: `nil`,
}, {
name: "two maps",
- maps: []event.TagMap{event.NewTagMap(B, C), event.NewTagMap(A)},
- keys: []event.Key{AKey, BKey, CKey},
+ maps: []core.TagMap{core.NewTagMap(B, C), core.NewTagMap(A)},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `A="a", B="b", C="c"`,
}, {
name: "invalid start map",
- maps: []event.TagMap{event.NewTagMap(), event.NewTagMap(B, C)},
- keys: []event.Key{AKey, BKey, CKey},
+ maps: []core.TagMap{core.NewTagMap(), core.NewTagMap(B, C)},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `nil, B="b", C="c"`,
}, {
name: "invalid mid map",
- maps: []event.TagMap{event.NewTagMap(A), event.NewTagMap(), event.NewTagMap(C)},
- keys: []event.Key{AKey, BKey, CKey},
+ maps: []core.TagMap{core.NewTagMap(A), core.NewTagMap(), core.NewTagMap(C)},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `A="a", nil, C="c"`,
}, {
name: "invalid end map",
- maps: []event.TagMap{event.NewTagMap(A, B), event.NewTagMap()},
- keys: []event.Key{AKey, BKey, CKey},
+ maps: []core.TagMap{core.NewTagMap(A, B), core.NewTagMap()},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `A="a", B="b", nil`,
}, {
name: "three maps one nil",
- maps: []event.TagMap{event.NewTagMap(A), event.NewTagMap(B), nil},
- keys: []event.Key{AKey, BKey, CKey},
+ maps: []core.TagMap{core.NewTagMap(A), core.NewTagMap(B), nil},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `A="a", B="b", nil`,
}, {
name: "two maps one nil",
- maps: []event.TagMap{event.NewTagMap(A, B), nil},
- keys: []event.Key{AKey, BKey, CKey},
+ maps: []core.TagMap{core.NewTagMap(A, B), nil},
+ keys: []core.Key{AKey, BKey, CKey},
expect: `A="a", B="b", nil`,
}} {
t.Run(test.name, func(t *testing.T) {
- tagMap := event.MergeTagMaps(test.maps...)
+ tagMap := core.MergeTagMaps(test.maps...)
got := printTagMap(tagMap, test.keys)
if got != test.expect {
t.Errorf("got %q want %q", got, test.expect)
@@ -241,7 +241,7 @@
}
}
-func printList(l event.TagList) string {
+func printList(l core.TagList) string {
buf := &bytes.Buffer{}
for index := 0; l.Valid(index); index++ {
tag := l.Tag(index)
@@ -256,7 +256,7 @@
return buf.String()
}
-func printTagMap(tagMap event.TagMap, keys []event.Key) string {
+func printTagMap(tagMap core.TagMap, keys []core.Key) string {
buf := &bytes.Buffer{}
for _, key := range keys {
if buf.Len() > 0 {
diff --git a/internal/telemetry/event/trace.go b/internal/event/core/trace.go
similarity index 98%
rename from internal/telemetry/event/trace.go
rename to internal/event/core/trace.go
index 2c40341..96354c5 100644
--- a/internal/telemetry/event/trace.go
+++ b/internal/event/core/trace.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package event
+package core
import (
"context"
diff --git a/internal/event/doc.go b/internal/event/doc.go
new file mode 100644
index 0000000..5dc6e6b
--- /dev/null
+++ b/internal/event/doc.go
@@ -0,0 +1,7 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package event provides a set of packages that cover the main
+// concepts of telemetry in an implementation agnostic way.
+package event
diff --git a/internal/event/event.go b/internal/event/event.go
new file mode 100644
index 0000000..bb950f6
--- /dev/null
+++ b/internal/event/event.go
@@ -0,0 +1,63 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package event
+
+import (
+ "context"
+
+ "golang.org/x/tools/internal/event/core"
+)
+
+// Exporter is a function that handles events.
+// It may return a modified context and event.
+type Exporter func(context.Context, core.Event, core.TagMap) context.Context
+
+// SetExporter sets the global exporter function that handles all events.
+// The exporter is called synchronously from the event call site, so it should
+// return quickly so as not to hold up user code.
+func SetExporter(e Exporter) {
+ core.SetExporter(core.Exporter(e))
+}
+
+// Log sends a log event with the supplied tag list to the exporter.
+func Log(ctx context.Context, tags ...core.Tag) {
+ core.Log(ctx, tags...)
+}
+
+// Print takes a message and a tag list and combines them into a single event
+// before delivering them to the exporter.
+func Print(ctx context.Context, message string, tags ...core.Tag) {
+ core.Print(ctx, message, tags...)
+}
+
+// Error takes a message and a tag list and combines them into a single event
+// before delivering them to the exporter. It captures the error in the
+// delivered event.
+func Error(ctx context.Context, message string, err error, tags ...core.Tag) {
+ core.Error(ctx, message, err, tags...)
+}
+
+// Record sends a label event to the exporter with the supplied tags.
+func Record(ctx context.Context, tags ...core.Tag) context.Context {
+ return core.Record(ctx, tags...)
+}
+
+// Label sends a label event to the exporter with the supplied tags.
+func Label(ctx context.Context, tags ...core.Tag) context.Context {
+ return core.Label(ctx, tags...)
+}
+
+// StartSpan sends a span start event with the supplied tag list to the exporter.
+// It also returns a function that will end the span, which should normally be
+// deferred.
+func StartSpan(ctx context.Context, name string, tags ...core.Tag) (context.Context, func()) {
+ return core.StartSpan(ctx, name, tags...)
+}
+
+// Detach returns a context without an associated span.
+// This allows the creation of spans that are not children of the current span.
+func Detach(ctx context.Context) context.Context {
+ return core.Detach(ctx)
+}
diff --git a/internal/telemetry/export/eventtest/eventtest.go b/internal/event/export/eventtest/eventtest.go
similarity index 87%
rename from internal/telemetry/export/eventtest/eventtest.go
rename to internal/event/export/eventtest/eventtest.go
index ae92166..d0061f7 100644
--- a/internal/telemetry/export/eventtest/eventtest.go
+++ b/internal/event/export/eventtest/eventtest.go
@@ -21,8 +21,9 @@
"sync"
"testing"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export"
)
func init() {
@@ -47,7 +48,7 @@
logger event.Exporter
}
-func (w *testExporter) processEvent(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+func (w *testExporter) processEvent(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
w.mu.Lock()
defer w.mu.Unlock()
// build our log message in buffer
diff --git a/internal/telemetry/export/id.go b/internal/event/export/id.go
similarity index 100%
rename from internal/telemetry/export/id.go
rename to internal/event/export/id.go
diff --git a/internal/telemetry/export/log.go b/internal/event/export/log.go
similarity index 80%
rename from internal/telemetry/export/log.go
rename to internal/event/export/log.go
index 8bc0360..22076aa 100644
--- a/internal/telemetry/export/log.go
+++ b/internal/event/export/log.go
@@ -10,7 +10,8 @@
"io"
"sync"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
)
// LogWriter returns an Exporter that logs events to the supplied writer.
@@ -29,10 +30,10 @@
onlyErrors bool
}
-func (w *logWriter) ProcessEvent(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+func (w *logWriter) ProcessEvent(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
switch {
case ev.IsLog():
- if w.onlyErrors && event.Err.Get(tagMap) == nil {
+ if w.onlyErrors && core.Err.Get(tagMap) == nil {
return ctx
}
w.mu.Lock()
@@ -42,15 +43,15 @@
if !ev.At.IsZero() {
w.writer.Write(ev.At.AppendFormat(buf, "2006/01/02 15:04:05 "))
}
- msg := event.Msg.Get(tagMap)
+ msg := core.Msg.Get(tagMap)
io.WriteString(w.writer, msg)
- if err := event.Err.Get(tagMap); err != nil {
+ if err := core.Err.Get(tagMap); err != nil {
io.WriteString(w.writer, ": ")
io.WriteString(w.writer, err.Error())
}
for index := 0; ev.Valid(index); index++ {
tag := ev.Tag(index)
- if !tag.Valid() || tag.Key() == event.Msg || tag.Key() == event.Err {
+ if !tag.Valid() || tag.Key() == core.Msg || tag.Key() == core.Err {
continue
}
io.WriteString(w.writer, "\n\t")
diff --git a/internal/telemetry/export/log_test.go b/internal/event/export/log_test.go
similarity index 71%
rename from internal/telemetry/export/log_test.go
rename to internal/event/export/log_test.go
index 77fa02c..0864e91 100644
--- a/internal/telemetry/export/log_test.go
+++ b/internal/event/export/log_test.go
@@ -10,15 +10,16 @@
"os"
"time"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export"
)
func ExampleLog() {
ctx := context.Background()
event.SetExporter(timeFixer(export.LogWriter(os.Stdout, false)))
- anInt := event.NewIntKey("myInt", "an integer")
- aString := event.NewStringKey("myString", "a string")
+ anInt := core.NewIntKey("myInt", "an integer")
+ aString := core.NewStringKey("myString", "a string")
event.Print(ctx, "my event", anInt.Of(6))
event.Error(ctx, "error event", errors.New("an error"), aString.Of("some string value"))
// Output:
@@ -30,7 +31,7 @@
func timeFixer(output event.Exporter) event.Exporter {
at, _ := time.Parse(time.RFC3339Nano, "2020-03-05T14:27:48Z")
- return func(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+ return func(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
ev.At = at
return output(ctx, ev, tagMap)
}
diff --git a/internal/telemetry/export/metric/data.go b/internal/event/export/metric/data.go
similarity index 74%
rename from internal/telemetry/export/metric/data.go
rename to internal/event/export/metric/data.go
index 33d7bf1..c960355 100644
--- a/internal/telemetry/export/metric/data.go
+++ b/internal/event/export/metric/data.go
@@ -9,7 +9,7 @@
"sort"
"time"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event/core"
)
// Data represents a single point in the time series of a metric.
@@ -22,7 +22,7 @@
//TODO: rethink the concept of metric handles
Handle() string
// Groups reports the rows that currently exist for this metric.
- Groups() [][]event.Tag
+ Groups() [][]core.Tag
}
// Int64Data is a concrete implementation of Data for int64 scalar metrics.
@@ -36,8 +36,8 @@
// End is the last time this metric was updated.
EndTime time.Time
- groups [][]event.Tag
- key *event.Int64Key
+ groups [][]core.Tag
+ key *core.Int64Key
}
// Float64Data is a concrete implementation of Data for float64 scalar metrics.
@@ -51,8 +51,8 @@
// End is the last time this metric was updated.
EndTime time.Time
- groups [][]event.Tag
- key *event.Float64Key
+ groups [][]core.Tag
+ key *core.Float64Key
}
// HistogramInt64Data is a concrete implementation of Data for int64 histogram metrics.
@@ -64,8 +64,8 @@
// End is the last time this metric was updated.
EndTime time.Time
- groups [][]event.Tag
- key *event.Int64Key
+ groups [][]core.Tag
+ key *core.Int64Key
}
// HistogramInt64Row holds the values for a single row of a HistogramInt64Data.
@@ -91,8 +91,8 @@
// End is the last time this metric was updated.
EndTime time.Time
- groups [][]event.Tag
- key *event.Float64Key
+ groups [][]core.Tag
+ key *core.Float64Key
}
// HistogramFloat64Row holds the values for a single row of a HistogramFloat64Data.
@@ -109,18 +109,18 @@
Max float64
}
-func tagListEqual(a, b []event.Tag) bool {
+func tagListEqual(a, b []core.Tag) bool {
//TODO: make this more efficient
return fmt.Sprint(a) == fmt.Sprint(b)
}
-func tagListLess(a, b []event.Tag) bool {
+func tagListLess(a, b []core.Tag) bool {
//TODO: make this more efficient
return fmt.Sprint(a) < fmt.Sprint(b)
}
-func getGroup(tagMap event.TagMap, g *[][]event.Tag, keys []event.Key) (int, bool) {
- group := make([]event.Tag, len(keys))
+func getGroup(tagMap core.TagMap, g *[][]core.Tag, keys []core.Key) (int, bool) {
+ group := make([]core.Tag, len(keys))
for i, key := range keys {
tag := tagMap.Find(key)
if tag.Valid() {
@@ -135,17 +135,17 @@
// not a new group
return index, false
}
- *g = make([][]event.Tag, len(old)+1)
+ *g = make([][]core.Tag, len(old)+1)
copy(*g, old[:index])
copy((*g)[index+1:], old[index:])
(*g)[index] = group
return index, true
}
-func (data *Int64Data) Handle() string { return data.Info.Name }
-func (data *Int64Data) Groups() [][]event.Tag { return data.groups }
+func (data *Int64Data) Handle() string { return data.Info.Name }
+func (data *Int64Data) Groups() [][]core.Tag { return data.groups }
-func (data *Int64Data) modify(at time.Time, tagMap event.TagMap, f func(v int64) int64) Data {
+func (data *Int64Data) modify(at time.Time, tagMap core.TagMap, f func(v int64) int64) Data {
index, insert := getGroup(tagMap, &data.groups, data.Info.Keys)
old := data.Rows
if insert {
@@ -162,28 +162,28 @@
return &frozen
}
-func (data *Int64Data) count(at time.Time, tagMap event.TagMap, tag event.Tag) Data {
+func (data *Int64Data) count(at time.Time, tagMap core.TagMap, tag core.Tag) Data {
return data.modify(at, tagMap, func(v int64) int64 {
return v + 1
})
}
-func (data *Int64Data) sum(at time.Time, tagMap event.TagMap, tag event.Tag) Data {
+func (data *Int64Data) sum(at time.Time, tagMap core.TagMap, tag core.Tag) Data {
return data.modify(at, tagMap, func(v int64) int64 {
return v + data.key.From(tag)
})
}
-func (data *Int64Data) latest(at time.Time, tagMap event.TagMap, tag event.Tag) Data {
+func (data *Int64Data) latest(at time.Time, tagMap core.TagMap, tag core.Tag) Data {
return data.modify(at, tagMap, func(v int64) int64 {
return data.key.From(tag)
})
}
-func (data *Float64Data) Handle() string { return data.Info.Name }
-func (data *Float64Data) Groups() [][]event.Tag { return data.groups }
+func (data *Float64Data) Handle() string { return data.Info.Name }
+func (data *Float64Data) Groups() [][]core.Tag { return data.groups }
-func (data *Float64Data) modify(at time.Time, tagMap event.TagMap, f func(v float64) float64) Data {
+func (data *Float64Data) modify(at time.Time, tagMap core.TagMap, f func(v float64) float64) Data {
index, insert := getGroup(tagMap, &data.groups, data.Info.Keys)
old := data.Rows
if insert {
@@ -200,22 +200,22 @@
return &frozen
}
-func (data *Float64Data) sum(at time.Time, tagMap event.TagMap, tag event.Tag) Data {
+func (data *Float64Data) sum(at time.Time, tagMap core.TagMap, tag core.Tag) Data {
return data.modify(at, tagMap, func(v float64) float64 {
return v + data.key.From(tag)
})
}
-func (data *Float64Data) latest(at time.Time, tagMap event.TagMap, tag event.Tag) Data {
+func (data *Float64Data) latest(at time.Time, tagMap core.TagMap, tag core.Tag) Data {
return data.modify(at, tagMap, func(v float64) float64 {
return data.key.From(tag)
})
}
-func (data *HistogramInt64Data) Handle() string { return data.Info.Name }
-func (data *HistogramInt64Data) Groups() [][]event.Tag { return data.groups }
+func (data *HistogramInt64Data) Handle() string { return data.Info.Name }
+func (data *HistogramInt64Data) Groups() [][]core.Tag { return data.groups }
-func (data *HistogramInt64Data) modify(at time.Time, tagMap event.TagMap, f func(v *HistogramInt64Row)) Data {
+func (data *HistogramInt64Data) modify(at time.Time, tagMap core.TagMap, f func(v *HistogramInt64Row)) Data {
index, insert := getGroup(tagMap, &data.groups, data.Info.Keys)
old := data.Rows
var v HistogramInt64Row
@@ -238,7 +238,7 @@
return &frozen
}
-func (data *HistogramInt64Data) record(at time.Time, tagMap event.TagMap, tag event.Tag) Data {
+func (data *HistogramInt64Data) record(at time.Time, tagMap core.TagMap, tag core.Tag) Data {
return data.modify(at, tagMap, func(v *HistogramInt64Row) {
value := data.key.From(tag)
v.Sum += value
@@ -257,10 +257,10 @@
})
}
-func (data *HistogramFloat64Data) Handle() string { return data.Info.Name }
-func (data *HistogramFloat64Data) Groups() [][]event.Tag { return data.groups }
+func (data *HistogramFloat64Data) Handle() string { return data.Info.Name }
+func (data *HistogramFloat64Data) Groups() [][]core.Tag { return data.groups }
-func (data *HistogramFloat64Data) modify(at time.Time, tagMap event.TagMap, f func(v *HistogramFloat64Row)) Data {
+func (data *HistogramFloat64Data) modify(at time.Time, tagMap core.TagMap, f func(v *HistogramFloat64Row)) Data {
index, insert := getGroup(tagMap, &data.groups, data.Info.Keys)
old := data.Rows
var v HistogramFloat64Row
@@ -283,7 +283,7 @@
return &frozen
}
-func (data *HistogramFloat64Data) record(at time.Time, tagMap event.TagMap, tag event.Tag) Data {
+func (data *HistogramFloat64Data) record(at time.Time, tagMap core.TagMap, tag core.Tag) Data {
return data.modify(at, tagMap, func(v *HistogramFloat64Row) {
value := data.key.From(tag)
v.Sum += value
diff --git a/internal/telemetry/export/metric/exporter.go b/internal/event/export/metric/exporter.go
similarity index 69%
rename from internal/telemetry/export/metric/exporter.go
rename to internal/event/export/metric/exporter.go
index ad3552f..c3653d9 100644
--- a/internal/telemetry/export/metric/exporter.go
+++ b/internal/event/export/metric/exporter.go
@@ -10,18 +10,19 @@
"sync"
"time"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
)
-var Entries = event.NewKey("metric_entries", "The set of metrics calculated for an event")
+var Entries = core.NewKey("metric_entries", "The set of metrics calculated for an event")
type Config struct {
subscribers map[interface{}][]subscriber
}
-type subscriber func(time.Time, event.TagMap, event.Tag) Data
+type subscriber func(time.Time, core.TagMap, core.Tag) Data
-func (e *Config) subscribe(key event.Key, s subscriber) {
+func (e *Config) subscribe(key core.Key, s subscriber) {
if e.subscribers == nil {
e.subscribers = make(map[interface{}][]subscriber)
}
@@ -30,7 +31,7 @@
func (e *Config) Exporter(output event.Exporter) event.Exporter {
var mu sync.Mutex
- return func(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+ return func(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
if !ev.IsRecord() {
return output(ctx, ev, tagMap)
}
@@ -49,7 +50,7 @@
}
}
}
- tagMap = event.MergeTagMaps(event.NewTagMap(Entries.Of(metrics)), tagMap)
+ tagMap = core.MergeTagMaps(core.NewTagMap(Entries.Of(metrics)), tagMap)
return output(ctx, ev, tagMap)
}
}
diff --git a/internal/telemetry/export/metric/info.go b/internal/event/export/metric/info.go
similarity index 85%
rename from internal/telemetry/export/metric/info.go
rename to internal/event/export/metric/info.go
index e2b2bf9..2d423d1 100644
--- a/internal/telemetry/export/metric/info.go
+++ b/internal/event/export/metric/info.go
@@ -4,9 +4,7 @@
package metric
-import (
- "golang.org/x/tools/internal/telemetry/event"
-)
+import "golang.org/x/tools/internal/event/core"
// Scalar represents the construction information for a scalar metric.
type Scalar struct {
@@ -15,7 +13,7 @@
// Description can be used by observers to describe the metric to users.
Description string
// Keys is the set of tags that collectively describe rows of the metric.
- Keys []event.Key
+ Keys []core.Key
}
// HistogramInt64 represents the construction information for an int64 histogram metric.
@@ -25,7 +23,7 @@
// Description can be used by observers to describe the metric to users.
Description string
// Keys is the set of tags that collectively describe rows of the metric.
- Keys []event.Key
+ Keys []core.Key
// Buckets holds the inclusive upper bound of each bucket in the histogram.
Buckets []int64
}
@@ -37,7 +35,7 @@
// Description can be used by observers to describe the metric to users.
Description string
// Keys is the set of tags that collectively describe rows of the metric.
- Keys []event.Key
+ Keys []core.Key
// Buckets holds the inclusive upper bound of each bucket in the histogram.
Buckets []float64
}
@@ -45,7 +43,7 @@
// Count creates a new metric based on the Scalar information that counts
// the number of times the supplied int64 measure is set.
// Metrics of this type will use Int64Data.
-func (info Scalar) Count(e *Config, key event.Key) {
+func (info Scalar) Count(e *Config, key core.Key) {
data := &Int64Data{Info: &info, key: nil}
e.subscribe(key, data.count)
}
@@ -53,7 +51,7 @@
// SumInt64 creates a new metric based on the Scalar information that sums all
// the values recorded on the int64 measure.
// Metrics of this type will use Int64Data.
-func (info Scalar) SumInt64(e *Config, key *event.Int64Key) {
+func (info Scalar) SumInt64(e *Config, key *core.Int64Key) {
data := &Int64Data{Info: &info, key: key}
e.subscribe(key, data.sum)
}
@@ -61,7 +59,7 @@
// LatestInt64 creates a new metric based on the Scalar information that tracks
// the most recent value recorded on the int64 measure.
// Metrics of this type will use Int64Data.
-func (info Scalar) LatestInt64(e *Config, key *event.Int64Key) {
+func (info Scalar) LatestInt64(e *Config, key *core.Int64Key) {
data := &Int64Data{Info: &info, IsGauge: true, key: key}
e.subscribe(key, data.latest)
}
@@ -69,7 +67,7 @@
// SumFloat64 creates a new metric based on the Scalar information that sums all
// the values recorded on the float64 measure.
// Metrics of this type will use Float64Data.
-func (info Scalar) SumFloat64(e *Config, key *event.Float64Key) {
+func (info Scalar) SumFloat64(e *Config, key *core.Float64Key) {
data := &Float64Data{Info: &info, key: key}
e.subscribe(key, data.sum)
}
@@ -77,7 +75,7 @@
// LatestFloat64 creates a new metric based on the Scalar information that tracks
// the most recent value recorded on the float64 measure.
// Metrics of this type will use Float64Data.
-func (info Scalar) LatestFloat64(e *Config, key *event.Float64Key) {
+func (info Scalar) LatestFloat64(e *Config, key *core.Float64Key) {
data := &Float64Data{Info: &info, IsGauge: true, key: key}
e.subscribe(key, data.latest)
}
@@ -85,7 +83,7 @@
// Record creates a new metric based on the HistogramInt64 information that
// tracks the bucketized counts of values recorded on the int64 measure.
// Metrics of this type will use HistogramInt64Data.
-func (info HistogramInt64) Record(e *Config, key *event.Int64Key) {
+func (info HistogramInt64) Record(e *Config, key *core.Int64Key) {
data := &HistogramInt64Data{Info: &info, key: key}
e.subscribe(key, data.record)
}
@@ -93,7 +91,7 @@
// Record creates a new metric based on the HistogramFloat64 information that
// tracks the bucketized counts of values recorded on the float64 measure.
// Metrics of this type will use HistogramFloat64Data.
-func (info HistogramFloat64) Record(e *Config, key *event.Float64Key) {
+func (info HistogramFloat64) Record(e *Config, key *core.Float64Key) {
data := &HistogramFloat64Data{Info: &info, key: key}
e.subscribe(key, data.record)
}
diff --git a/internal/telemetry/export/ocagent/README.md b/internal/event/export/ocagent/README.md
similarity index 95%
rename from internal/telemetry/export/ocagent/README.md
rename to internal/event/export/ocagent/README.md
index d1d2699..22e8469 100644
--- a/internal/telemetry/export/ocagent/README.md
+++ b/internal/event/export/ocagent/README.md
@@ -37,10 +37,10 @@
"net/http"
"time"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export"
- "golang.org/x/tools/internal/telemetry/export/metric"
- "golang.org/x/tools/internal/telemetry/export/ocagent"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/export"
+ "golang.org/x/tools/internal/event/export/metric"
+ "golang.org/x/tools/internal/event/export/ocagent"
)
type testExporter struct {
diff --git a/internal/telemetry/export/ocagent/metrics.go b/internal/event/export/ocagent/metrics.go
similarity index 95%
rename from internal/telemetry/export/ocagent/metrics.go
rename to internal/event/export/ocagent/metrics.go
index 0d0d464..3250c4f 100644
--- a/internal/telemetry/export/ocagent/metrics.go
+++ b/internal/event/export/ocagent/metrics.go
@@ -7,9 +7,9 @@
import (
"time"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export/metric"
- "golang.org/x/tools/internal/telemetry/export/ocagent/wire"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export/metric"
+ "golang.org/x/tools/internal/event/export/ocagent/wire"
)
// dataToMetricDescriptor return a *wire.MetricDescriptor based on data.
@@ -201,7 +201,7 @@
// infoKeysToLabelKeys returns an array of *wire.LabelKeys containing the
// string values of the elements of labelKeys.
-func infoKeysToLabelKeys(infoKeys []event.Key) []*wire.LabelKey {
+func infoKeysToLabelKeys(infoKeys []core.Key) []*wire.LabelKey {
labelKeys := make([]*wire.LabelKey, 0, len(infoKeys))
for _, key := range infoKeys {
labelKeys = append(labelKeys, &wire.LabelKey{
diff --git a/internal/telemetry/export/ocagent/metrics_test.go b/internal/event/export/ocagent/metrics_test.go
similarity index 93%
rename from internal/telemetry/export/ocagent/metrics_test.go
rename to internal/event/export/ocagent/metrics_test.go
index 0c21655..84cec6c 100644
--- a/internal/telemetry/export/ocagent/metrics_test.go
+++ b/internal/event/export/ocagent/metrics_test.go
@@ -5,7 +5,8 @@
"errors"
"testing"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
)
func TestEncodeMetric(t *testing.T) {
@@ -23,7 +24,7 @@
run: func(ctx context.Context) {
ctx = event.Label(ctx, keyMethod.Of("godoc.ServeHTTP"))
event.Record(ctx, latencyMs.Of(96.58))
- ctx = event.Label(ctx, event.Err.Of(errors.New("panic: fatal signal")))
+ ctx = event.Label(ctx, core.Err.Of(errors.New("panic: fatal signal")))
event.Record(ctx, bytesIn.Of(97e2))
},
want: prefix + `
diff --git a/internal/telemetry/export/ocagent/ocagent.go b/internal/event/export/ocagent/ocagent.go
similarity index 85%
rename from internal/telemetry/export/ocagent/ocagent.go
rename to internal/event/export/ocagent/ocagent.go
index 0d1af1a..0f10592 100644
--- a/internal/telemetry/export/ocagent/ocagent.go
+++ b/internal/event/export/ocagent/ocagent.go
@@ -18,10 +18,10 @@
"sync"
"time"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export"
- "golang.org/x/tools/internal/telemetry/export/metric"
- "golang.org/x/tools/internal/telemetry/export/ocagent/wire"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export"
+ "golang.org/x/tools/internal/event/export/metric"
+ "golang.org/x/tools/internal/event/export/ocagent/wire"
)
type Config struct {
@@ -85,7 +85,7 @@
return exporter
}
-func (e *Exporter) ProcessEvent(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+func (e *Exporter) ProcessEvent(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
switch {
case ev.IsEndSpan():
e.mu.Lock()
@@ -200,7 +200,7 @@
Kind: wire.UnspecifiedSpanKind,
StartTime: convertTimestamp(span.Start().At),
EndTime: convertTimestamp(span.Finish().At),
- Attributes: convertAttributes(event.Filter(span.Start(), event.Name)),
+ Attributes: convertAttributes(core.Filter(span.Start(), core.Name)),
TimeEvents: convertEvents(span.Events()),
SameProcessAsParentSpan: true,
//TODO: StackTrace?
@@ -227,17 +227,17 @@
}
}
-func skipToValidTag(l event.TagList) (int, event.Tag) {
+func skipToValidTag(l core.TagList) (int, core.Tag) {
// skip to the first valid tag
for index := 0; l.Valid(index); index++ {
if tag := l.Tag(index); tag.Valid() {
return index, tag
}
}
- return -1, event.Tag{}
+ return -1, core.Tag{}
}
-func convertAttributes(l event.TagList) *wire.Attributes {
+func convertAttributes(l core.TagList) *wire.Attributes {
index, tag := skipToValidTag(l)
if !tag.Valid() {
return nil
@@ -255,46 +255,46 @@
}
}
-func convertAttribute(tag event.Tag) wire.Attribute {
+func convertAttribute(tag core.Tag) wire.Attribute {
switch key := tag.Key().(type) {
- case *event.IntKey:
+ case *core.IntKey:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.Int8Key:
+ case *core.Int8Key:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.Int16Key:
+ case *core.Int16Key:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.Int32Key:
+ case *core.Int32Key:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.Int64Key:
+ case *core.Int64Key:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.UIntKey:
+ case *core.UIntKey:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.UInt8Key:
+ case *core.UInt8Key:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.UInt16Key:
+ case *core.UInt16Key:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.UInt32Key:
+ case *core.UInt32Key:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.UInt64Key:
+ case *core.UInt64Key:
return wire.IntAttribute{IntValue: int64(key.From(tag))}
- case *event.Float32Key:
+ case *core.Float32Key:
return wire.DoubleAttribute{DoubleValue: float64(key.From(tag))}
- case *event.Float64Key:
+ case *core.Float64Key:
return wire.DoubleAttribute{DoubleValue: key.From(tag)}
- case *event.BooleanKey:
+ case *core.BooleanKey:
return wire.BoolAttribute{BoolValue: key.From(tag)}
- case *event.StringKey:
+ case *core.StringKey:
return wire.StringAttribute{StringValue: toTruncatableString(key.From(tag))}
- case *event.ErrorKey:
+ case *core.ErrorKey:
return wire.StringAttribute{StringValue: toTruncatableString(key.From(tag).Error())}
- case *event.ValueKey:
+ case *core.ValueKey:
return wire.StringAttribute{StringValue: toTruncatableString(fmt.Sprint(key.From(tag)))}
default:
return wire.StringAttribute{StringValue: toTruncatableString(fmt.Sprintf("%T", key))}
}
}
-func convertEvents(events []event.Event) *wire.TimeEvents {
+func convertEvents(events []core.Event) *wire.TimeEvents {
//TODO: MessageEvents?
result := make([]wire.TimeEvent, len(events))
for i, event := range events {
@@ -303,23 +303,23 @@
return &wire.TimeEvents{TimeEvent: result}
}
-func convertEvent(ev event.Event) wire.TimeEvent {
+func convertEvent(ev core.Event) wire.TimeEvent {
return wire.TimeEvent{
Time: convertTimestamp(ev.At),
Annotation: convertAnnotation(ev),
}
}
-func convertAnnotation(ev event.Event) *wire.Annotation {
+func convertAnnotation(ev core.Event) *wire.Annotation {
if _, tag := skipToValidTag(ev); !tag.Valid() {
return nil
}
- tagMap := event.TagMap(ev)
- description := event.Msg.Get(tagMap)
- tags := event.Filter(ev, event.Msg)
+ tagMap := core.TagMap(ev)
+ description := core.Msg.Get(tagMap)
+ tags := core.Filter(ev, core.Msg)
if description == "" {
- err := event.Err.Get(tagMap)
- tags = event.Filter(tags, event.Err)
+ err := core.Err.Get(tagMap)
+ tags = core.Filter(tags, core.Err)
if err != nil {
description = err.Error()
}
diff --git a/internal/telemetry/export/ocagent/ocagent_test.go b/internal/event/export/ocagent/ocagent_test.go
similarity index 64%
rename from internal/telemetry/export/ocagent/ocagent_test.go
rename to internal/event/export/ocagent/ocagent_test.go
index 36ca0e7..c1f2f95 100644
--- a/internal/telemetry/export/ocagent/ocagent_test.go
+++ b/internal/event/export/ocagent/ocagent_test.go
@@ -15,10 +15,11 @@
"testing"
"time"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export"
- "golang.org/x/tools/internal/telemetry/export/metric"
- "golang.org/x/tools/internal/telemetry/export/ocagent"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export"
+ "golang.org/x/tools/internal/event/export/metric"
+ "golang.org/x/tools/internal/event/export/ocagent"
)
const testNodeStr = `{
@@ -39,53 +40,53 @@
},`
var (
- keyDB = event.NewStringKey("db", "the database name")
- keyMethod = event.NewStringKey("method", "a metric grouping key")
- keyRoute = event.NewStringKey("route", "another metric grouping key")
+ keyDB = core.NewStringKey("db", "the database name")
+ keyMethod = core.NewStringKey("method", "a metric grouping key")
+ keyRoute = core.NewStringKey("route", "another metric grouping key")
- key1DB = event.NewStringKey("1_db", "A test string key")
+ key1DB = core.NewStringKey("1_db", "A test string key")
- key2aAge = event.NewFloat64Key("2a_age", "A test float64 key")
- key2bTTL = event.NewFloat32Key("2b_ttl", "A test float32 key")
- key2cExpiryMS = event.NewFloat64Key("2c_expiry_ms", "A test float64 key")
+ key2aAge = core.NewFloat64Key("2a_age", "A test float64 key")
+ key2bTTL = core.NewFloat32Key("2b_ttl", "A test float32 key")
+ key2cExpiryMS = core.NewFloat64Key("2c_expiry_ms", "A test float64 key")
- key3aRetry = event.NewBooleanKey("3a_retry", "A test boolean key")
- key3bStale = event.NewBooleanKey("3b_stale", "Another test boolean key")
+ key3aRetry = core.NewBooleanKey("3a_retry", "A test boolean key")
+ key3bStale = core.NewBooleanKey("3b_stale", "Another test boolean key")
- key4aMax = event.NewIntKey("4a_max", "A test int key")
- key4bOpcode = event.NewInt8Key("4b_opcode", "A test int8 key")
- key4cBase = event.NewInt16Key("4c_base", "A test int16 key")
- key4eChecksum = event.NewInt32Key("4e_checksum", "A test int32 key")
- key4fMode = event.NewInt64Key("4f_mode", "A test int64 key")
+ key4aMax = core.NewIntKey("4a_max", "A test int key")
+ key4bOpcode = core.NewInt8Key("4b_opcode", "A test int8 key")
+ key4cBase = core.NewInt16Key("4c_base", "A test int16 key")
+ key4eChecksum = core.NewInt32Key("4e_checksum", "A test int32 key")
+ key4fMode = core.NewInt64Key("4f_mode", "A test int64 key")
- key5aMin = event.NewUIntKey("5a_min", "A test uint key")
- key5bMix = event.NewUInt8Key("5b_mix", "A test uint8 key")
- key5cPort = event.NewUInt16Key("5c_port", "A test uint16 key")
- key5dMinHops = event.NewUInt32Key("5d_min_hops", "A test uint32 key")
- key5eMaxHops = event.NewUInt64Key("5e_max_hops", "A test uint64 key")
+ key5aMin = core.NewUIntKey("5a_min", "A test uint key")
+ key5bMix = core.NewUInt8Key("5b_mix", "A test uint8 key")
+ key5cPort = core.NewUInt16Key("5c_port", "A test uint16 key")
+ key5dMinHops = core.NewUInt32Key("5d_min_hops", "A test uint32 key")
+ key5eMaxHops = core.NewUInt64Key("5e_max_hops", "A test uint64 key")
- recursiveCalls = event.NewInt64Key("recursive_calls", "Number of recursive calls")
- bytesIn = event.NewInt64Key("bytes_in", "Number of bytes in") //, unit.Bytes)
- latencyMs = event.NewFloat64Key("latency", "The latency in milliseconds") //, unit.Milliseconds)
+ recursiveCalls = core.NewInt64Key("recursive_calls", "Number of recursive calls")
+ bytesIn = core.NewInt64Key("bytes_in", "Number of bytes in") //, unit.Bytes)
+ latencyMs = core.NewFloat64Key("latency", "The latency in milliseconds") //, unit.Milliseconds)
metricLatency = metric.HistogramFloat64{
Name: "latency_ms",
Description: "The latency of calls in milliseconds",
- Keys: []event.Key{keyMethod, keyRoute},
+ Keys: []core.Key{keyMethod, keyRoute},
Buckets: []float64{0, 5, 10, 25, 50},
}
metricBytesIn = metric.HistogramInt64{
Name: "latency_ms",
Description: "The latency of calls in milliseconds",
- Keys: []event.Key{keyMethod, keyRoute},
+ Keys: []core.Key{keyMethod, keyRoute},
Buckets: []int64{0, 10, 50, 100, 500, 1000, 2000},
}
metricRecursiveCalls = metric.Scalar{
Name: "latency_ms",
Description: "The latency of calls in milliseconds",
- Keys: []event.Key{keyMethod, keyRoute},
+ Keys: []core.Key{keyMethod, keyRoute},
}
)
@@ -124,7 +125,7 @@
start, _ := time.Parse(time.RFC3339Nano, "1970-01-01T00:00:30Z")
at, _ := time.Parse(time.RFC3339Nano, "1970-01-01T00:00:40Z")
end, _ := time.Parse(time.RFC3339Nano, "1970-01-01T00:00:50Z")
- return func(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+ return func(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
switch {
case ev.IsStartSpan():
ev.At = start
@@ -138,7 +139,7 @@
}
func spanFixer(output event.Exporter) event.Exporter {
- return func(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+ return func(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
if ev.IsStartSpan() {
span := export.GetSpan(ctx)
span.ID = export.SpanContext{}
diff --git a/internal/telemetry/export/ocagent/trace_test.go b/internal/event/export/ocagent/trace_test.go
similarity index 98%
rename from internal/telemetry/export/ocagent/trace_test.go
rename to internal/event/export/ocagent/trace_test.go
index f565168..77df1d7 100644
--- a/internal/telemetry/export/ocagent/trace_test.go
+++ b/internal/event/export/ocagent/trace_test.go
@@ -9,7 +9,7 @@
"errors"
"testing"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event"
)
func TestTrace(t *testing.T) {
diff --git a/internal/telemetry/export/ocagent/wire/common.go b/internal/event/export/ocagent/wire/common.go
similarity index 100%
rename from internal/telemetry/export/ocagent/wire/common.go
rename to internal/event/export/ocagent/wire/common.go
diff --git a/internal/telemetry/export/ocagent/wire/core.go b/internal/event/export/ocagent/wire/core.go
similarity index 100%
rename from internal/telemetry/export/ocagent/wire/core.go
rename to internal/event/export/ocagent/wire/core.go
diff --git a/internal/telemetry/export/ocagent/wire/metrics.go b/internal/event/export/ocagent/wire/metrics.go
similarity index 100%
rename from internal/telemetry/export/ocagent/wire/metrics.go
rename to internal/event/export/ocagent/wire/metrics.go
diff --git a/internal/telemetry/export/ocagent/wire/metrics_test.go b/internal/event/export/ocagent/wire/metrics_test.go
similarity index 100%
rename from internal/telemetry/export/ocagent/wire/metrics_test.go
rename to internal/event/export/ocagent/wire/metrics_test.go
diff --git a/internal/telemetry/export/ocagent/wire/trace.go b/internal/event/export/ocagent/wire/trace.go
similarity index 100%
rename from internal/telemetry/export/ocagent/wire/trace.go
rename to internal/event/export/ocagent/wire/trace.go
diff --git a/internal/telemetry/export/prometheus/prometheus.go b/internal/event/export/prometheus/prometheus.go
similarity index 92%
rename from internal/telemetry/export/prometheus/prometheus.go
rename to internal/event/export/prometheus/prometheus.go
index eb644dd..129f260 100644
--- a/internal/telemetry/export/prometheus/prometheus.go
+++ b/internal/event/export/prometheus/prometheus.go
@@ -12,8 +12,8 @@
"sort"
"sync"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export/metric"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export/metric"
)
func New() *Exporter {
@@ -25,7 +25,7 @@
metrics []metric.Data
}
-func (e *Exporter) ProcessEvent(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+func (e *Exporter) ProcessEvent(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
if !ev.IsRecord() {
return ctx
}
@@ -64,7 +64,7 @@
fmt.Fprintf(w, "# TYPE %s %s\n", name, kind)
}
-func (e *Exporter) row(w http.ResponseWriter, name string, group []event.Tag, extra string, value interface{}) {
+func (e *Exporter) row(w http.ResponseWriter, name string, group []core.Tag, extra string, value interface{}) {
fmt.Fprint(w, name)
buf := &bytes.Buffer{}
fmt.Fprint(buf, group)
diff --git a/internal/telemetry/export/tag.go b/internal/event/export/tag.go
similarity index 70%
rename from internal/telemetry/export/tag.go
rename to internal/event/export/tag.go
index 7d29529..bc2ecb4 100644
--- a/internal/telemetry/export/tag.go
+++ b/internal/event/export/tag.go
@@ -7,7 +7,8 @@
import (
"context"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
)
// Labels builds an exporter that manipulates the context using the event.
@@ -16,20 +17,20 @@
// For all other event types the event tags will be updated with values from the
// context if they are missing.
func Labels(output event.Exporter) event.Exporter {
- return func(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
- stored, _ := ctx.Value(labelContextKey).(event.TagMap)
+ return func(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
+ stored, _ := ctx.Value(labelContextKey).(core.TagMap)
if ev.IsLabel() || ev.IsStartSpan() {
// update the tag source stored in the context
- fromEvent := event.TagMap(ev)
+ fromEvent := core.TagMap(ev)
if stored == nil {
stored = fromEvent
} else {
- stored = event.MergeTagMaps(fromEvent, stored)
+ stored = core.MergeTagMaps(fromEvent, stored)
}
ctx = context.WithValue(ctx, labelContextKey, stored)
}
// add the stored tag context to the tag source
- tagMap = event.MergeTagMaps(tagMap, stored)
+ tagMap = core.MergeTagMaps(tagMap, stored)
return output(ctx, ev, tagMap)
}
}
diff --git a/internal/telemetry/export/trace.go b/internal/event/export/trace.go
similarity index 85%
rename from internal/telemetry/export/trace.go
rename to internal/event/export/trace.go
index 48e3863..528fdad 100644
--- a/internal/telemetry/export/trace.go
+++ b/internal/event/export/trace.go
@@ -9,7 +9,8 @@
"fmt"
"sync"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
)
type SpanContext struct {
@@ -22,9 +23,9 @@
ID SpanContext
ParentID SpanID
mu sync.Mutex
- start event.Event
- finish event.Event
- events []event.Event
+ start core.Event
+ finish core.Event
+ events []core.Event
}
type contextKeyType int
@@ -48,7 +49,7 @@
// EventLog or EventTag, and closes the span on EventEndSpan.
// The span structure can then be used by other exporters.
func Spans(output event.Exporter) event.Exporter {
- return func(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+ return func(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
switch {
case ev.IsLog(), ev.IsLabel():
if span := GetSpan(ctx); span != nil {
@@ -58,7 +59,7 @@
}
case ev.IsStartSpan():
span := &Span{
- Name: event.Name.Get(tagMap),
+ Name: core.Name.Get(tagMap),
start: ev,
}
if parent := GetSpan(ctx); parent != nil {
@@ -86,18 +87,18 @@
fmt.Fprintf(f, "%v:%v", s.TraceID, s.SpanID)
}
-func (s *Span) Start() event.Event {
+func (s *Span) Start() core.Event {
// start never changes after construction, so we dont need to hold the mutex
return s.start
}
-func (s *Span) Finish() event.Event {
+func (s *Span) Finish() core.Event {
s.mu.Lock()
defer s.mu.Unlock()
return s.finish
}
-func (s *Span) Events() []event.Event {
+func (s *Span) Events() []core.Event {
s.mu.Lock()
defer s.mu.Unlock()
return s.events
diff --git a/internal/gocommand/invoke.go b/internal/gocommand/invoke.go
index 19ecaea..9aa7984 100644
--- a/internal/gocommand/invoke.go
+++ b/internal/gocommand/invoke.go
@@ -17,7 +17,7 @@
"sync"
"time"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event"
)
// An Runner will run go command invocations and serialize
diff --git a/internal/jsonrpc2/handler.go b/internal/jsonrpc2/handler.go
index 0cd106f2..b861b12 100644
--- a/internal/jsonrpc2/handler.go
+++ b/internal/jsonrpc2/handler.go
@@ -9,7 +9,7 @@
"fmt"
"sync"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event"
)
// Handler is invoked to handle incoming requests.
diff --git a/internal/jsonrpc2/jsonrpc2.go b/internal/jsonrpc2/jsonrpc2.go
index f340dc5..5ee2c85 100644
--- a/internal/jsonrpc2/jsonrpc2.go
+++ b/internal/jsonrpc2/jsonrpc2.go
@@ -14,8 +14,9 @@
"sync"
"sync/atomic"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
"golang.org/x/tools/internal/lsp/debug/tag"
- "golang.org/x/tools/internal/telemetry/event"
)
const (
@@ -172,7 +173,7 @@
}
switch msg := msg.(type) {
case Request:
- tags := []event.Tag{
+ tags := []core.Tag{
tag.Method.Of(msg.Method()),
tag.RPCDirection.Of(tag.Inbound),
{}, // reserved for ID if present
diff --git a/internal/jsonrpc2/jsonrpc2_test.go b/internal/jsonrpc2/jsonrpc2_test.go
index a733558..b7232ca 100644
--- a/internal/jsonrpc2/jsonrpc2_test.go
+++ b/internal/jsonrpc2/jsonrpc2_test.go
@@ -16,8 +16,8 @@
"sync"
"testing"
+ "golang.org/x/tools/internal/event/export/eventtest"
"golang.org/x/tools/internal/jsonrpc2"
- "golang.org/x/tools/internal/telemetry/export/eventtest"
)
var logRPC = flag.Bool("logrpc", false, "Enable jsonrpc2 communication logging")
diff --git a/internal/jsonrpc2/serve.go b/internal/jsonrpc2/serve.go
index d3d8370..6415b0e 100644
--- a/internal/jsonrpc2/serve.go
+++ b/internal/jsonrpc2/serve.go
@@ -11,7 +11,7 @@
"os"
"time"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event"
)
// NOTE: This file provides an experimental API for serving multiple remote
diff --git a/internal/lsp/cache/analysis.go b/internal/lsp/cache/analysis.go
index 563d3b5..5868e73 100644
--- a/internal/lsp/cache/analysis.go
+++ b/internal/lsp/cache/analysis.go
@@ -16,10 +16,10 @@
"golang.org/x/sync/errgroup"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/internal/analysisinternal"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/memoize"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/cache/check.go b/internal/lsp/cache/check.go
index d85786b..bdde37e 100644
--- a/internal/lsp/cache/check.go
+++ b/internal/lsp/cache/check.go
@@ -17,11 +17,11 @@
"sync"
"golang.org/x/tools/go/packages"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/memoize"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/cache/errors.go b/internal/lsp/cache/errors.go
index 40f5596..14995b9 100644
--- a/internal/lsp/cache/errors.go
+++ b/internal/lsp/cache/errors.go
@@ -17,11 +17,11 @@
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/packages"
"golang.org/x/tools/internal/analysisinternal"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/cache/external.go b/internal/lsp/cache/external.go
index 806499a..1c46ea0 100644
--- a/internal/lsp/cache/external.go
+++ b/internal/lsp/cache/external.go
@@ -9,10 +9,10 @@
"io/ioutil"
"os"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go
index 880d6f8..c530137 100644
--- a/internal/lsp/cache/load.go
+++ b/internal/lsp/cache/load.go
@@ -12,11 +12,11 @@
"strings"
"golang.org/x/tools/go/packages"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/packagesinternal"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/cache/mod.go b/internal/lsp/cache/mod.go
index 4619633..ae36704 100644
--- a/internal/lsp/cache/mod.go
+++ b/internal/lsp/cache/mod.go
@@ -15,6 +15,7 @@
"golang.org/x/mod/modfile"
"golang.org/x/tools/go/packages"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/gocommand"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
@@ -22,7 +23,6 @@
"golang.org/x/tools/internal/memoize"
"golang.org/x/tools/internal/packagesinternal"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/cache/parse.go b/internal/lsp/cache/parse.go
index ca78935..4f01fcb 100644
--- a/internal/lsp/cache/parse.go
+++ b/internal/lsp/cache/parse.go
@@ -13,12 +13,12 @@
"go/token"
"reflect"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/memoize"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/cache/session.go b/internal/lsp/cache/session.go
index 40d8ee7..4f3bffb 100644
--- a/internal/lsp/cache/session.go
+++ b/internal/lsp/cache/session.go
@@ -11,11 +11,11 @@
"sync"
"sync/atomic"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/gocommand"
"golang.org/x/tools/internal/lsp/debug"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
"golang.org/x/tools/internal/xcontext"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go
index 013ba0d..0648c80 100644
--- a/internal/lsp/cache/snapshot.go
+++ b/internal/lsp/cache/snapshot.go
@@ -17,11 +17,11 @@
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/packages"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/packagesinternal"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go
index c9c90d5..4a87d82 100644
--- a/internal/lsp/cache/view.go
+++ b/internal/lsp/cache/view.go
@@ -19,6 +19,8 @@
"sync"
"time"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
"golang.org/x/tools/internal/gocommand"
"golang.org/x/tools/internal/imports"
"golang.org/x/tools/internal/lsp/debug"
@@ -26,7 +28,6 @@
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/memoize"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
"golang.org/x/tools/internal/xcontext"
errors "golang.org/x/xerrors"
)
@@ -344,7 +345,7 @@
// We don't have a context handy to use for logging, so use the stdlib for now.
event.Print(v.baseCtx, "background imports cache refresh starting")
err := imports.PrimeCache(context.Background(), env)
- event.Print(v.baseCtx, fmt.Sprintf("background refresh finished after %v", time.Since(start)), event.Err.Of(err))
+ event.Print(v.baseCtx, fmt.Sprintf("background refresh finished after %v", time.Since(start)), core.Err.Of(err))
v.importsMu.Lock()
v.cacheRefreshDuration = time.Since(start)
diff --git a/internal/lsp/cmd/serve.go b/internal/lsp/cmd/serve.go
index 05fdbb6..9790070 100644
--- a/internal/lsp/cmd/serve.go
+++ b/internal/lsp/cmd/serve.go
@@ -12,12 +12,12 @@
"strings"
"time"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/lsp/cache"
"golang.org/x/tools/internal/lsp/debug"
"golang.org/x/tools/internal/lsp/lsprpc"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
"golang.org/x/tools/internal/tool"
)
diff --git a/internal/lsp/completion.go b/internal/lsp/completion.go
index edc2b08..f6d3049 100644
--- a/internal/lsp/completion.go
+++ b/internal/lsp/completion.go
@@ -9,10 +9,10 @@
"fmt"
"strings"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
- "golang.org/x/tools/internal/telemetry/event"
)
func (s *Server) completion(ctx context.Context, params *protocol.CompletionParams) (*protocol.CompletionList, error) {
diff --git a/internal/lsp/debug/metrics.go b/internal/lsp/debug/metrics.go
index 4861b41..94b582e 100644
--- a/internal/lsp/debug/metrics.go
+++ b/internal/lsp/debug/metrics.go
@@ -5,9 +5,9 @@
package debug
import (
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export/metric"
"golang.org/x/tools/internal/lsp/debug/tag"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export/metric"
)
var (
@@ -18,34 +18,34 @@
receivedBytes = metric.HistogramInt64{
Name: "received_bytes",
Description: "Distribution of received bytes, by method.",
- Keys: []event.Key{tag.RPCDirection, tag.Method},
+ Keys: []core.Key{tag.RPCDirection, tag.Method},
Buckets: bytesDistribution,
}
sentBytes = metric.HistogramInt64{
Name: "sent_bytes",
Description: "Distribution of sent bytes, by method.",
- Keys: []event.Key{tag.RPCDirection, tag.Method},
+ Keys: []core.Key{tag.RPCDirection, tag.Method},
Buckets: bytesDistribution,
}
latency = metric.HistogramFloat64{
Name: "latency",
Description: "Distribution of latency in milliseconds, by method.",
- Keys: []event.Key{tag.RPCDirection, tag.Method},
+ Keys: []core.Key{tag.RPCDirection, tag.Method},
Buckets: millisecondsDistribution,
}
started = metric.Scalar{
Name: "started",
Description: "Count of RPCs started by method.",
- Keys: []event.Key{tag.RPCDirection, tag.Method},
+ Keys: []core.Key{tag.RPCDirection, tag.Method},
}
completed = metric.Scalar{
Name: "completed",
Description: "Count of RPCs completed by method and status.",
- Keys: []event.Key{tag.RPCDirection, tag.Method, tag.StatusCode},
+ Keys: []core.Key{tag.RPCDirection, tag.Method, tag.StatusCode},
}
)
diff --git a/internal/lsp/debug/rpc.go b/internal/lsp/debug/rpc.go
index e1c93e2..4bbca75 100644
--- a/internal/lsp/debug/rpc.go
+++ b/internal/lsp/debug/rpc.go
@@ -13,9 +13,9 @@
"sync"
"time"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export"
"golang.org/x/tools/internal/lsp/debug/tag"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export"
)
var rpcTmpl = template.Must(template.Must(baseTemplate.Clone()).Parse(`
@@ -77,7 +77,7 @@
Count int64
}
-func (r *rpcs) ProcessEvent(ctx context.Context, ev event.Event, tagMap event.TagMap) context.Context {
+func (r *rpcs) ProcessEvent(ctx context.Context, ev core.Event, tagMap core.TagMap) context.Context {
r.mu.Lock()
defer r.mu.Unlock()
switch {
@@ -103,7 +103,7 @@
return ctx
}
-func endRPC(ctx context.Context, ev event.Event, span *export.Span, stats *rpcStats) {
+func endRPC(ctx context.Context, ev core.Event, span *export.Span, stats *rpcStats) {
// update the basic counts
stats.Completed++
@@ -150,7 +150,7 @@
}
}
-func (r *rpcs) getRPCSpan(ctx context.Context, ev event.Event) (*export.Span, *rpcStats) {
+func (r *rpcs) getRPCSpan(ctx context.Context, ev core.Event) (*export.Span, *rpcStats) {
// get the span
span := export.GetSpan(ctx)
if span == nil {
@@ -161,7 +161,7 @@
return span, r.getRPCStats(span.Start())
}
-func (r *rpcs) getRPCStats(tagMap event.TagMap) *rpcStats {
+func (r *rpcs) getRPCStats(tagMap core.TagMap) *rpcStats {
method := tag.Method.Get(tagMap)
if method == "" {
return nil
diff --git a/internal/lsp/debug/serve.go b/internal/lsp/debug/serve.go
index c5781e5..2a1c736 100644
--- a/internal/lsp/debug/serve.go
+++ b/internal/lsp/debug/serve.go
@@ -26,14 +26,15 @@
"sync"
"time"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export"
+ "golang.org/x/tools/internal/event/export/metric"
+ "golang.org/x/tools/internal/event/export/ocagent"
+ "golang.org/x/tools/internal/event/export/prometheus"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export"
- "golang.org/x/tools/internal/telemetry/export/metric"
- "golang.org/x/tools/internal/telemetry/export/ocagent"
- "golang.org/x/tools/internal/telemetry/export/prometheus"
"golang.org/x/xerrors"
)
@@ -542,12 +543,12 @@
}
func makeGlobalExporter(stderr io.Writer) event.Exporter {
- return func(ctx context.Context, ev event.Event, tags event.TagMap) context.Context {
+ return func(ctx context.Context, ev core.Event, tags core.TagMap) context.Context {
i := GetInstance(ctx)
if ev.IsLog() {
// Don't log context cancellation errors.
- if err := event.Err.Get(ev); xerrors.Is(err, context.Canceled) {
+ if err := core.Err.Get(ev); xerrors.Is(err, context.Canceled) {
return ctx
}
// Make sure any log messages without an instance go to stderr.
@@ -564,7 +565,7 @@
}
func makeInstanceExporter(i *Instance) event.Exporter {
- exporter := func(ctx context.Context, ev event.Event, tags event.TagMap) context.Context {
+ exporter := func(ctx context.Context, ev core.Event, tags core.TagMap) context.Context {
if i.ocagent != nil {
ctx = i.ocagent.ProcessEvent(ctx, ev, tags)
}
diff --git a/internal/lsp/debug/tag/tag.go b/internal/lsp/debug/tag/tag.go
index 22f1b23..4250a1c 100644
--- a/internal/lsp/debug/tag/tag.go
+++ b/internal/lsp/debug/tag/tag.go
@@ -6,40 +6,40 @@
package tag
import (
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event/core"
)
var (
// create the tag keys we use
- Method = event.NewStringKey("method", "")
- StatusCode = event.NewStringKey("status.code", "")
- StatusMessage = event.NewStringKey("status.message", "")
- RPCID = event.NewStringKey("id", "")
- RPCDirection = event.NewStringKey("direction", "")
- File = event.NewStringKey("file", "")
- Directory = event.NewKey("directory", "")
- URI = event.NewKey("URI", "")
- Package = event.NewStringKey("package", "")
- PackagePath = event.NewStringKey("package_path", "")
- Query = event.NewKey("query", "")
- Snapshot = event.NewUInt64Key("snapshot", "")
- Operation = event.NewStringKey("operation", "")
+ Method = core.NewStringKey("method", "")
+ StatusCode = core.NewStringKey("status.code", "")
+ StatusMessage = core.NewStringKey("status.message", "")
+ RPCID = core.NewStringKey("id", "")
+ RPCDirection = core.NewStringKey("direction", "")
+ File = core.NewStringKey("file", "")
+ Directory = core.NewKey("directory", "")
+ URI = core.NewKey("URI", "")
+ Package = core.NewStringKey("package", "")
+ PackagePath = core.NewStringKey("package_path", "")
+ Query = core.NewKey("query", "")
+ Snapshot = core.NewUInt64Key("snapshot", "")
+ Operation = core.NewStringKey("operation", "")
- Position = event.NewKey("position", "")
- Category = event.NewStringKey("category", "")
- PackageCount = event.NewIntKey("packages", "")
- Files = event.NewKey("files", "")
- Port = event.NewIntKey("port", "")
- Type = event.NewKey("type", "")
- HoverKind = event.NewStringKey("hoverkind", "")
+ Position = core.NewKey("position", "")
+ Category = core.NewStringKey("category", "")
+ PackageCount = core.NewIntKey("packages", "")
+ Files = core.NewKey("files", "")
+ Port = core.NewIntKey("port", "")
+ Type = core.NewKey("type", "")
+ HoverKind = core.NewStringKey("hoverkind", "")
)
var (
// create the stats we measure
- Started = event.NewInt64Key("started", "Count of started RPCs.")
- ReceivedBytes = event.NewInt64Key("received_bytes", "Bytes received.") //, unit.Bytes)
- SentBytes = event.NewInt64Key("sent_bytes", "Bytes sent.") //, unit.Bytes)
- Latency = event.NewFloat64Key("latency_ms", "Elapsed time in milliseconds") //, unit.Milliseconds)
+ Started = core.NewInt64Key("started", "Count of started RPCs.")
+ ReceivedBytes = core.NewInt64Key("received_bytes", "Bytes received.") //, unit.Bytes)
+ SentBytes = core.NewInt64Key("sent_bytes", "Bytes sent.") //, unit.Bytes)
+ Latency = core.NewFloat64Key("latency_ms", "Elapsed time in milliseconds") //, unit.Milliseconds)
)
const (
diff --git a/internal/lsp/debug/trace.go b/internal/lsp/debug/trace.go
index 0ae32c9..2ad2cda 100644
--- a/internal/lsp/debug/trace.go
+++ b/internal/lsp/debug/trace.go
@@ -15,8 +15,8 @@
"sync"
"time"
- "golang.org/x/tools/internal/telemetry/event"
- "golang.org/x/tools/internal/telemetry/export"
+ "golang.org/x/tools/internal/event/core"
+ "golang.org/x/tools/internal/event/export"
)
var traceTmpl = template.Must(template.Must(baseTemplate.Clone()).Parse(`
@@ -73,7 +73,7 @@
Tags string
}
-func (t *traces) ProcessEvent(ctx context.Context, ev event.Event, tags event.TagMap) context.Context {
+func (t *traces) ProcessEvent(ctx context.Context, ev core.Event, tags core.TagMap) context.Context {
t.mu.Lock()
defer t.mu.Unlock()
span := export.GetSpan(ctx)
@@ -170,7 +170,7 @@
}
}
-func renderTags(tags event.TagList) string {
+func renderTags(tags core.TagList) string {
buf := &bytes.Buffer{}
for index := 0; tags.Valid(index); index++ {
if tag := tags.Tag(index); tag.Valid() {
diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go
index 94592be..14ad61d 100644
--- a/internal/lsp/diagnostics.go
+++ b/internal/lsp/diagnostics.go
@@ -9,11 +9,11 @@
"strings"
"sync"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/mod"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
- "golang.org/x/tools/internal/telemetry/event"
"golang.org/x/tools/internal/xcontext"
)
diff --git a/internal/lsp/general.go b/internal/lsp/general.go
index 6e13670..296966b 100644
--- a/internal/lsp/general.go
+++ b/internal/lsp/general.go
@@ -12,13 +12,13 @@
"os"
"path"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/lsp/debug"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
)
func (s *Server) initialize(ctx context.Context, params *protocol.ParamInitialize) (*protocol.InitializeResult, error) {
diff --git a/internal/lsp/generate.go b/internal/lsp/generate.go
index 2bcd037..054b765 100644
--- a/internal/lsp/generate.go
+++ b/internal/lsp/generate.go
@@ -10,10 +10,10 @@
"math/rand"
"strconv"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/gocommand"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
"golang.org/x/xerrors"
)
diff --git a/internal/lsp/highlight.go b/internal/lsp/highlight.go
index 9ff37e9..ef72c54 100644
--- a/internal/lsp/highlight.go
+++ b/internal/lsp/highlight.go
@@ -7,10 +7,10 @@
import (
"context"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
- "golang.org/x/tools/internal/telemetry/event"
)
func (s *Server) documentHighlight(ctx context.Context, params *protocol.DocumentHighlightParams) ([]protocol.DocumentHighlight, error) {
diff --git a/internal/lsp/link.go b/internal/lsp/link.go
index 2003ba4..ddb4e76 100644
--- a/internal/lsp/link.go
+++ b/internal/lsp/link.go
@@ -17,11 +17,11 @@
"sync"
"golang.org/x/mod/modfile"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
)
func (s *Server) documentLink(ctx context.Context, params *protocol.DocumentLinkParams) (links []protocol.DocumentLink, err error) {
diff --git a/internal/lsp/lsprpc/lsprpc.go b/internal/lsp/lsprpc/lsprpc.go
index 5662591..89cf894 100644
--- a/internal/lsp/lsprpc/lsprpc.go
+++ b/internal/lsp/lsprpc/lsprpc.go
@@ -18,12 +18,12 @@
"time"
"golang.org/x/sync/errgroup"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/lsp"
"golang.org/x/tools/internal/lsp/cache"
"golang.org/x/tools/internal/lsp/debug"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
)
// AutoNetwork is the pseudo network type used to signal that gopls should use
diff --git a/internal/lsp/lsprpc/lsprpc_test.go b/internal/lsp/lsprpc/lsprpc_test.go
index 67db214..cc2a40f 100644
--- a/internal/lsp/lsprpc/lsprpc_test.go
+++ b/internal/lsp/lsprpc/lsprpc_test.go
@@ -11,13 +11,13 @@
"testing"
"time"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/jsonrpc2/servertest"
"golang.org/x/tools/internal/lsp/cache"
"golang.org/x/tools/internal/lsp/debug"
"golang.org/x/tools/internal/lsp/fake"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
)
type fakeClient struct {
diff --git a/internal/lsp/mod/code_lens.go b/internal/lsp/mod/code_lens.go
index c07fc0d..096bfba 100644
--- a/internal/lsp/mod/code_lens.go
+++ b/internal/lsp/mod/code_lens.go
@@ -6,11 +6,11 @@
"strings"
"golang.org/x/mod/modfile"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
)
func CodeLens(ctx context.Context, snapshot source.Snapshot, uri span.URI) ([]protocol.CodeLens, error) {
diff --git a/internal/lsp/mod/diagnostics.go b/internal/lsp/mod/diagnostics.go
index df407ee..5b64fa9 100644
--- a/internal/lsp/mod/diagnostics.go
+++ b/internal/lsp/mod/diagnostics.go
@@ -10,10 +10,10 @@
"context"
"golang.org/x/mod/modfile"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
- "golang.org/x/tools/internal/telemetry/event"
)
func Diagnostics(ctx context.Context, snapshot source.Snapshot) (map[source.FileIdentity][]*source.Diagnostic, map[string]*modfile.Require, error) {
diff --git a/internal/lsp/mod/format.go b/internal/lsp/mod/format.go
index 4f97ce4..060877f 100644
--- a/internal/lsp/mod/format.go
+++ b/internal/lsp/mod/format.go
@@ -3,9 +3,9 @@
import (
"context"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
- "golang.org/x/tools/internal/telemetry/event"
)
func Format(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle) ([]protocol.TextEdit, error) {
diff --git a/internal/lsp/mod/hover.go b/internal/lsp/mod/hover.go
index 4e26096..bab9f5f 100644
--- a/internal/lsp/mod/hover.go
+++ b/internal/lsp/mod/hover.go
@@ -8,10 +8,10 @@
"strings"
"golang.org/x/mod/modfile"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
)
func Hover(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, position protocol.Position) (*protocol.Hover, error) {
diff --git a/internal/lsp/protocol/context.go b/internal/lsp/protocol/context.go
index 560de4d..d526e2c 100644
--- a/internal/lsp/protocol/context.go
+++ b/internal/lsp/protocol/context.go
@@ -4,7 +4,7 @@
"context"
"fmt"
- "golang.org/x/tools/internal/telemetry/event"
+ "golang.org/x/tools/internal/event/core"
"golang.org/x/tools/internal/xcontext"
)
@@ -18,7 +18,7 @@
return context.WithValue(ctx, clientKey, client)
}
-func LogEvent(ctx context.Context, ev event.Event, tags event.TagMap) context.Context {
+func LogEvent(ctx context.Context, ev core.Event, tags core.TagMap) context.Context {
if !ev.IsLog() {
return ctx
}
@@ -27,7 +27,7 @@
return ctx
}
msg := &LogMessageParams{Type: Info, Message: fmt.Sprint(ev)}
- if event.Err.Get(tags) != nil {
+ if core.Err.Get(tags) != nil {
msg.Type = Error
}
go client.LogMessage(xcontext.Detach(ctx), msg)
diff --git a/internal/lsp/protocol/protocol.go b/internal/lsp/protocol/protocol.go
index 8dded05..18e9181 100644
--- a/internal/lsp/protocol/protocol.go
+++ b/internal/lsp/protocol/protocol.go
@@ -9,8 +9,8 @@
"encoding/json"
"fmt"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/jsonrpc2"
- "golang.org/x/tools/internal/telemetry/event"
"golang.org/x/tools/internal/xcontext"
)
diff --git a/internal/lsp/signature_help.go b/internal/lsp/signature_help.go
index 8bf43f6..fad317d 100644
--- a/internal/lsp/signature_help.go
+++ b/internal/lsp/signature_help.go
@@ -7,10 +7,11 @@
import (
"context"
+ "golang.org/x/tools/internal/event"
+ "golang.org/x/tools/internal/event/core"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
- "golang.org/x/tools/internal/telemetry/event"
)
func (s *Server) signatureHelp(ctx context.Context, params *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error) {
@@ -20,7 +21,7 @@
}
info, activeParameter, err := source.SignatureHelp(ctx, snapshot, fh, params.Position)
if err != nil {
- event.Print(ctx, "no signature help", tag.Position.Of(params.Position), event.Err.Of(err))
+ event.Print(ctx, "no signature help", tag.Position.Of(params.Position), core.Err.Of(err))
return nil, nil
}
return &protocol.SignatureHelp{
diff --git a/internal/lsp/source/completion.go b/internal/lsp/source/completion.go
index e3defa2..39a7576 100644
--- a/internal/lsp/source/completion.go
+++ b/internal/lsp/source/completion.go
@@ -20,11 +20,11 @@
"time"
"golang.org/x/tools/go/ast/astutil"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/imports"
"golang.org/x/tools/internal/lsp/fuzzy"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/snippet"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/completion_format.go b/internal/lsp/source/completion_format.go
index 88ff102..9b2c0c7 100644
--- a/internal/lsp/source/completion_format.go
+++ b/internal/lsp/source/completion_format.go
@@ -11,12 +11,12 @@
"go/types"
"strings"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/imports"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/snippet"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/completion_literal.go b/internal/lsp/source/completion_literal.go
index fa6c71a..381c4c4 100644
--- a/internal/lsp/source/completion_literal.go
+++ b/internal/lsp/source/completion_literal.go
@@ -12,10 +12,10 @@
"strings"
"unicode"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/diff"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/snippet"
- "golang.org/x/tools/internal/telemetry/event"
)
// literal generates composite literal, function literal, and make()
diff --git a/internal/lsp/source/diagnostics.go b/internal/lsp/source/diagnostics.go
index 67fbe75..8691674 100644
--- a/internal/lsp/source/diagnostics.go
+++ b/internal/lsp/source/diagnostics.go
@@ -13,10 +13,10 @@
"golang.org/x/mod/modfile"
"golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/format.go b/internal/lsp/source/format.go
index c6c96fd..5b92ab6 100644
--- a/internal/lsp/source/format.go
+++ b/internal/lsp/source/format.go
@@ -14,11 +14,11 @@
"go/scanner"
"go/token"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/imports"
"golang.org/x/tools/internal/lsp/diff"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/highlight.go b/internal/lsp/source/highlight.go
index 5b92a26..0917aee 100644
--- a/internal/lsp/source/highlight.go
+++ b/internal/lsp/source/highlight.go
@@ -13,8 +13,8 @@
"strings"
"golang.org/x/tools/go/ast/astutil"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/hover.go b/internal/lsp/source/hover.go
index b15cccb..9b85b66 100644
--- a/internal/lsp/source/hover.go
+++ b/internal/lsp/source/hover.go
@@ -14,8 +14,8 @@
"go/types"
"strings"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/identifier.go b/internal/lsp/source/identifier.go
index f6e7907..f11c4e5 100644
--- a/internal/lsp/source/identifier.go
+++ b/internal/lsp/source/identifier.go
@@ -13,8 +13,8 @@
"strconv"
"golang.org/x/tools/go/ast/astutil"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/implementation.go b/internal/lsp/source/implementation.go
index 29da25f..ddebb48 100644
--- a/internal/lsp/source/implementation.go
+++ b/internal/lsp/source/implementation.go
@@ -12,8 +12,8 @@
"go/token"
"go/types"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
)
func Implementation(ctx context.Context, s Snapshot, f FileHandle, pp protocol.Position) ([]protocol.Location, error) {
diff --git a/internal/lsp/source/references.go b/internal/lsp/source/references.go
index a6d35e8..0cc4922 100644
--- a/internal/lsp/source/references.go
+++ b/internal/lsp/source/references.go
@@ -10,8 +10,8 @@
"go/token"
"go/types"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
"golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/rename.go b/internal/lsp/source/rename.go
index 6f79e26..c0026b6 100644
--- a/internal/lsp/source/rename.go
+++ b/internal/lsp/source/rename.go
@@ -14,10 +14,10 @@
"regexp"
"golang.org/x/tools/go/types/typeutil"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/diff"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/span"
- "golang.org/x/tools/internal/telemetry/event"
"golang.org/x/tools/refactor/satisfy"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/signature_help.go b/internal/lsp/source/signature_help.go
index 20d2431..e658492 100644
--- a/internal/lsp/source/signature_help.go
+++ b/internal/lsp/source/signature_help.go
@@ -13,8 +13,8 @@
"go/types"
"golang.org/x/tools/go/ast/astutil"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
errors "golang.org/x/xerrors"
)
diff --git a/internal/lsp/source/symbols.go b/internal/lsp/source/symbols.go
index 8b09f81..bc4e2b7 100644
--- a/internal/lsp/source/symbols.go
+++ b/internal/lsp/source/symbols.go
@@ -10,8 +10,8 @@
"go/ast"
"go/types"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
)
func DocumentSymbols(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]protocol.DocumentSymbol, error) {
diff --git a/internal/lsp/source/workspace_symbol.go b/internal/lsp/source/workspace_symbol.go
index 5d458a5..70f730a 100644
--- a/internal/lsp/source/workspace_symbol.go
+++ b/internal/lsp/source/workspace_symbol.go
@@ -11,9 +11,9 @@
"go/types"
"strings"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/fuzzy"
"golang.org/x/tools/internal/lsp/protocol"
- "golang.org/x/tools/internal/telemetry/event"
)
const maxSymbols = 100
diff --git a/internal/lsp/symbols.go b/internal/lsp/symbols.go
index 11e89e1..59eb52c 100644
--- a/internal/lsp/symbols.go
+++ b/internal/lsp/symbols.go
@@ -7,10 +7,10 @@
import (
"context"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
- "golang.org/x/tools/internal/telemetry/event"
)
func (s *Server) documentSymbol(ctx context.Context, params *protocol.DocumentSymbolParams) ([]interface{}, error) {
diff --git a/internal/lsp/workspace_symbol.go b/internal/lsp/workspace_symbol.go
index d26a507..07718f9 100644
--- a/internal/lsp/workspace_symbol.go
+++ b/internal/lsp/workspace_symbol.go
@@ -7,9 +7,9 @@
import (
"context"
+ "golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
- "golang.org/x/tools/internal/telemetry/event"
)
func (s *Server) symbol(ctx context.Context, params *protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error) {
diff --git a/internal/telemetry/doc.go b/internal/telemetry/doc.go
deleted file mode 100644
index 2e38886..0000000
--- a/internal/telemetry/doc.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package telemetry provides a set of packages that cover the main
-// concepts of telemetry in an implementation agnostic way.
-// The interface for libraries that want to expose telemetry is the event
-// package.
-// As a binary author you might look at exporter for methods of exporting the
-// telemetry to external tools.
-package telemetry