Proposals Unofficial Go proposal tracker

Add goroutine labels identifying the running test

#75047 · testing · medium impact · Accepted ·

When several tests hang and time out, the goroutine dump does not show which goroutine belongs to which test. This makes timeouts hard to debug and hides tests that spawn many goroutines.

The testing package will now set two goroutine labels automatically on every test, example, benchmark, and fuzz test:

  • test.name: the unqualified name of the test function.
  • test.iter: an identifier unique to each run of the test function (usually the iteration count).

Goroutines started by the test inherit these labels.

func TestFoo(t *testing.T) {
    v, _ := pprof.Label(t.Context(), "test.name") // "TestFoo"
    _ = v
}
Proposal
#75047 by dfinkel
Status
Accepted on Sep 23, 2026
Impact
medium
Area
testing