Skip to content

Commit 2926c1f

Browse files
committed
gopls/internal/telemetry: log timestamp when test fails
We observed a couple of test failures. My current hypothesis is that the bug is in how countertest.ReadCounter and countertest.ReadStackCounter read the data. They try to access the counter values by reading the contents of the mapped file on disk and parsing them with counter.Parse. They call 'file.rotate' before reading the files to ensure the file is mapped. However, if file.rotate ends up actually rotating the underlying file (due to crossing the UTC day boundary), the counter data may be flushed out and reset. As we are moving to 'week' instead of 'day' for file rotation, I don't know how frequently we will encounter this issue though if this was the root cause. Log the timestamp when the test fails, to evaluate the hypothesis. For golang/go#62161 Change-Id: If00b0788b6927640a979d17f8fe888232d27ea09 Reviewed-on: https://go-review.googlesource.com/c/tools/+/523795 Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: Gopher Robot <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Jamal Carvalho <[email protected]>
1 parent cd22603 commit 2926c1f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

gopls/internal/telemetry/telemetry_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strconv"
1313
"strings"
1414
"testing"
15+
"time"
1516

1617
"golang.org/x/telemetry/counter"
1718
"golang.org/x/telemetry/counter/countertest" // requires go1.21+
@@ -58,6 +59,7 @@ func TestTelemetry(t *testing.T) {
5859
count, err := countertest.ReadCounter(c)
5960
if err != nil || count != 1 {
6061
t.Errorf("ReadCounter(%q) = (%v, %v), want (1, nil)", c.Name(), count, err)
62+
t.Logf("Current timestamp = %v", time.Now().UTC())
6163
}
6264
}
6365

@@ -69,6 +71,7 @@ func TestTelemetry(t *testing.T) {
6971
}
7072
if len(counts) != 1 || !hasEntry(counts, t.Name(), 1) {
7173
t.Errorf("read stackcounter(%q) = (%#v, %v), want one entry", "gopls/bug", counts, err)
74+
t.Logf("Current timestamp = %v", time.Now().UTC())
7275
}
7376
}
7477

0 commit comments

Comments
 (0)