diff --git a/internal/debug/api.go b/internal/debug/api.go
index 048b7d76359c2f945c20d315da039c4e7fc9c332..86a4218f6a57fefce223e5f380c325acead4db99 100644
--- a/internal/debug/api.go
+++ b/internal/debug/api.go
@@ -21,6 +21,7 @@
 package debug
 
 import (
+	"bytes"
 	"errors"
 	"io"
 	"os"
@@ -190,9 +191,9 @@ func (*HandlerT) WriteMemProfile(file string) error {
 
 // Stacks returns a printed representation of the stacks of all goroutines.
 func (*HandlerT) Stacks() string {
-	buf := make([]byte, 1024*1024)
-	buf = buf[:runtime.Stack(buf, true)]
-	return string(buf)
+	buf := new(bytes.Buffer)
+	pprof.Lookup("goroutine").WriteTo(buf, 2)
+	return buf.String()
 }
 
 // FreeOSMemory returns unused memory to the OS.