gopls/internal/lsp/debug: limit to 100 recent trace entries

Before this CL, we would keep traces for up to a minute, even if we
exceeded the maximum number of recent traces. This could lead to an
unusable trace debug page, as traces can be very chatty during large
operations.

Change the condition to enforce a strict limit on the number of traces
to keep, and remove age-based eviction.

Change-Id: Ie9b44e2c5ef236c3e23e3eb21b7eb55da74295da
Reviewed-on: https://go-review.googlesource.com/c/tools/+/495259
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
diff --git a/gopls/internal/lsp/debug/trace.go b/gopls/internal/lsp/debug/trace.go
index 48bed9d..31c5a53 100644
--- a/gopls/internal/lsp/debug/trace.go
+++ b/gopls/internal/lsp/debug/trace.go
@@ -259,13 +259,10 @@
 // addRecentLocked appends a start or end event to the "recent" log,
 // evicting an old entry if necessary.
 func (t *traces) addRecentLocked(span *traceSpan, start bool) {
-	const (
-		maxRecent = 100 // number of log entries before age-based eviction
-		maxAge    = 1 * time.Minute
-	)
 	t.recent = append(t.recent, spanStartEnd{Start: start, Span: span})
 
-	for len(t.recent) > maxRecent && t.recent[0].Time().Before(time.Now().Add(-maxAge)) {
+	const maxRecent = 100 // number of log entries before eviction
+	for len(t.recent) > maxRecent {
 		t.recent[0] = spanStartEnd{} // aid GC
 		t.recent = t.recent[1:]
 		t.recentEvictions++