Skip to content

Commit a6c03c8

Browse files
adonovangopherbot
authored andcommitted
x/tools: update telemetry import (new Start API)
Change-Id: I78701b620029a94b47524f5d4a77c35a86df2e4e Reviewed-on: https://go-review.googlesource.com/c/tools/+/564337 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Alan Donovan <[email protected]> Commit-Queue: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 1f7dbdf commit a6c03c8

File tree

9 files changed

+26
-27
lines changed

9 files changed

+26
-27
lines changed

cmd/deadcode/deadcode.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import (
2626
"strings"
2727
"text/template"
2828

29-
"golang.org/x/telemetry/counter"
30-
"golang.org/x/telemetry/crashmonitor"
29+
"golang.org/x/telemetry"
3130
"golang.org/x/tools/go/callgraph"
3231
"golang.org/x/tools/go/callgraph/rta"
3332
"golang.org/x/tools/go/packages"
@@ -65,8 +64,7 @@ Flags:
6564
}
6665

6766
func main() {
68-
counter.Open() // Enable telemetry counter writing.
69-
crashmonitor.Start() // Enable crash reporting watchdog.
67+
telemetry.Start(telemetry.Config{ReportCrashes: true})
7068

7169
log.SetPrefix("deadcode: ")
7270
log.SetFlags(0) // no time prefix

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ require golang.org/x/sync v0.6.0
1212

1313
require (
1414
golang.org/x/sys v0.17.0 // indirect
15-
golang.org/x/telemetry v0.0.0-20240208230135-b75ee8823808
15+
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2
1616
)

go.sum

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
88
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
99
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
1010
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
11-
golang.org/x/telemetry v0.0.0-20240201224847-0a1d30dda509 h1:Nr7eTQpQZ/ytesxDJpQgaf0t4sdLnnDtAbmtViTrSUo=
12-
golang.org/x/telemetry v0.0.0-20240201224847-0a1d30dda509/go.mod h1:ZthVHHkOi8rlMEsfFr3Ie42Ym1NonbFNNRKW3ci0UrU=
13-
golang.org/x/telemetry v0.0.0-20240208230135-b75ee8823808 h1:+Kc94D8UVEVxJnLXp/+FMfqQARZtWHfVrcRtcG8aT3g=
14-
golang.org/x/telemetry v0.0.0-20240208230135-b75ee8823808/go.mod h1:KG1lNk5ZFNssSZLrpVb4sMXKMpGwGXOxSG3rnu2gZQQ=
11+
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 h1:IRJeR9r1pYWsHKTRe/IInb7lYvbBVIqOgsX/u0mbOWY=
12+
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=

gopls/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/jba/templatecheck v0.7.0
99
golang.org/x/mod v0.15.0
1010
golang.org/x/sync v0.6.0
11-
golang.org/x/telemetry v0.0.0-20240209200032-7b892fcb8a78
11+
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2
1212
golang.org/x/text v0.14.0
1313
golang.org/x/tools v0.18.0
1414
golang.org/x/vuln v1.0.1

gopls/go.sum

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2727
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2828
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
2929
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
30-
golang.org/x/telemetry v0.0.0-20240208230135-b75ee8823808/go.mod h1:KG1lNk5ZFNssSZLrpVb4sMXKMpGwGXOxSG3rnu2gZQQ=
31-
golang.org/x/telemetry v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
32-
golang.org/x/telemetry v0.0.0-20240209200032-7b892fcb8a78/go.mod h1:KG1lNk5ZFNssSZLrpVb4sMXKMpGwGXOxSG3rnu2gZQQ=
30+
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 h1:IRJeR9r1pYWsHKTRe/IInb7lYvbBVIqOgsX/u0mbOWY=
31+
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
3332
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
3433
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
3534
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

gopls/internal/telemetry/telemetry.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@ import (
1616
"golang.org/x/telemetry/upload"
1717
)
1818

19-
// CounterOpen calls [counter.Open].
20-
func CounterOpen() {
21-
counter.Open()
22-
}
23-
24-
// StartCrashMonitor calls [crashmonitor.Start].
25-
func StartCrashMonitor() {
26-
crashmonitor.Start()
19+
// Start starts telemetry, including the crash monitor.
20+
func Start() {
21+
telemetry.Start(telemetry.Config{ReportCrashes: true})
2722
}
2823

2924
// CrashMonitorSupported calls [crashmonitor.Supported].

gopls/internal/telemetry/telemetry_go118.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ package telemetry
1212
// gopls may not refer to the telemetry module directly, but must go
1313
// through this file.
1414

15-
func CounterOpen() {}
16-
17-
func StartCrashMonitor() {}
15+
func Start() {}
1816

1917
func CrashMonitorSupported() bool { return false }
2018

gopls/internal/telemetry/telemetry_test.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestTelemetry(t *testing.T) {
5959
for i, c := range sessionCounters {
6060
count, err := countertest.ReadCounter(c)
6161
if err != nil {
62-
t.Fatalf("ReadCounter(%s): %v", c.Name(), err)
62+
continue // counter db not open, or counter not found
6363
}
6464
initialCounts[i] = count
6565
}
@@ -74,7 +74,19 @@ func TestTelemetry(t *testing.T) {
7474
goversion = strconv.Itoa(env.GoVersion())
7575
addForwardedCounters(env, []string{"vscode/linter:a"}, []int64{1})
7676
const desc = "got a bug"
77+
78+
// This will increment a counter named something like:
79+
//
80+
// `gopls/bug
81+
// golang.org/x/tools/gopls/internal/util/bug.report:+35
82+
// golang.org/x/tools/gopls/internal/util/bug.Report:=68
83+
// golang.org/x/tools/gopls/internal/telemetry_test.TestTelemetry.func2:+4
84+
// golang.org/x/tools/gopls/internal/test/integration.(*Runner).Run.func1:+87
85+
// testing.tRunner:+150
86+
// runtime.goexit:+0`
87+
//
7788
bug.Report(desc) // want a stack counter with the trace starting from here.
89+
7890
env.Await(ShownMessage(desc))
7991
})
8092

gopls/main.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ var version = "" // if set by the linker, overrides the gopls version
2929
func main() {
3030
versionpkg.VersionOverride = version
3131

32-
telemetry.CounterOpen()
33-
telemetry.StartCrashMonitor()
32+
telemetry.Start()
3433
ctx := context.Background()
3534
tool.Main(ctx, cmd.New(hooks.Options), os.Args[1:])
3635
}

0 commit comments

Comments
 (0)