diff --git a/gopls/internal/bug/bug.go b/gopls/internal/bug/bug.go index f72948bec87..7331ba8c85c 100644 --- a/gopls/internal/bug/bug.go +++ b/gopls/internal/bug/bug.go @@ -18,6 +18,8 @@ import ( "sort" "sync" "time" + + "golang.org/x/telemetry/counter" ) // PanicOnBugs controls whether to panic when bugs are reported. @@ -63,6 +65,8 @@ func Report(description string) { report(description) } +var bugReport = counter.NewStack("gopls/bug", 16) + func report(description string) { _, file, line, ok := runtime.Caller(2) // all exported reporting functions call report directly @@ -84,17 +88,22 @@ func report(description string) { AtTime: time.Now(), } + newBug := false mu.Lock() if _, ok := exemplars[key]; !ok { if exemplars == nil { exemplars = make(map[string]Bug) } exemplars[key] = bug // capture one exemplar per key + newBug = true } hh := handlers handlers = nil mu.Unlock() + if newBug { + bugReport.Inc() + } // Call the handlers outside the critical section since a // handler may itself fail and call bug.Report. Since handlers // are one-shot, the inner call should be trivial.