Skip to content

Commit e603756

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/cache: add telemetry counter for GOPACKAGESDRIVER
Update a counter each time we observe a gopackages driver in use. This will help us understand the conditions that led to some crashes reported by telemetry. Updates golang/go#60890 Change-Id: Ieca522c22b6f5bc9756210627bba82934946eaf8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/594955 Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 42b921c commit e603756

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

gopls/internal/server/general.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,24 @@ func (s *server) newFolder(ctx context.Context, folder protocol.DocumentURI, nam
472472
// Increment folder counters.
473473
switch {
474474
case env.GOTOOLCHAIN == "auto" || strings.Contains(env.GOTOOLCHAIN, "+auto"):
475-
counter.New("gopls/gotoolchain:auto").Inc()
475+
counter.Inc("gopls/gotoolchain:auto")
476476
case env.GOTOOLCHAIN == "path" || strings.Contains(env.GOTOOLCHAIN, "+path"):
477-
counter.New("gopls/gotoolchain:path").Inc()
477+
counter.Inc("gopls/gotoolchain:path")
478478
case env.GOTOOLCHAIN == "local": // local+auto and local+path handled above
479-
counter.New("gopls/gotoolchain:local").Inc()
479+
counter.Inc("gopls/gotoolchain:local")
480480
default:
481-
counter.New("gopls/gotoolchain:other").Inc()
481+
counter.Inc("gopls/gotoolchain:other")
482+
}
483+
484+
// Record whether a driver is in use so that it appears in the
485+
// user's telemetry upload. Although we can't correlate the
486+
// driver information with the crash or bug.Report at the
487+
// granularity of the process instance, users that use a
488+
// driver tend to do so most of the time, so we'll get a
489+
// strong clue. See #60890 for an example of an issue where
490+
// this information would have been helpful.
491+
if env.EffectiveGOPACKAGESDRIVER != "" {
492+
counter.Inc("gopls/gopackagesdriver")
482493
}
483494

484495
return &cache.Folder{

0 commit comments

Comments
 (0)