Skip to content

Commit 3486735

Browse files
seankhliaomvdan
authored andcommitted
net/http/pprof: link docs to runtime/pprof
And add some documentation for the debug query param. Fixes #27737 Fixes #53971 Change-Id: I629aaa2d4a43175381eb04872f1caad238519a41 Reviewed-on: https://go-review.googlesource.com/c/go/+/421635 Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Reviewed-by: Daniel Martí <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 3680b5e commit 3486735

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/net/http/pprof/pprof.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@
2121
// log.Println(http.ListenAndServe("localhost:6060", nil))
2222
// }()
2323
//
24+
// By default, all the profiles listed in [runtime/pprof.Profile] are
25+
// available (via [Handler]), in addition to the [Cmdline], [Profile], [Symbol],
26+
// and [Trace] profiles defined in this package.
2427
// If you are not using DefaultServeMux, you will have to register handlers
2528
// with the mux you are using.
2629
//
27-
// Then use the pprof tool to look at the heap profile:
30+
// # Usage examples
31+
//
32+
// Use the pprof tool to look at the heap profile:
2833
//
2934
// go tool pprof http://localhost:6060/debug/pprof/heap
3035
//
@@ -222,6 +227,7 @@ func Symbol(w http.ResponseWriter, r *http.Request) {
222227
}
223228

224229
// Handler returns an HTTP handler that serves the named profile.
230+
// Available profiles can be found in [runtime/pprof.Profile].
225231
func Handler(name string) http.Handler {
226232
return handler(name)
227233
}
@@ -345,7 +351,7 @@ var profileDescriptions = map[string]string{
345351
"allocs": "A sampling of all past memory allocations",
346352
"block": "Stack traces that led to blocking on synchronization primitives",
347353
"cmdline": "The command line invocation of the current program",
348-
"goroutine": "Stack traces of all current goroutines",
354+
"goroutine": "Stack traces of all current goroutines. Use debug=2 as a query parameter to export in the same format as an unrecovered panic.",
349355
"heap": "A sampling of memory allocations of live objects. You can specify the gc GET parameter to run GC before taking the heap sample.",
350356
"mutex": "Stack traces of holders of contended mutexes",
351357
"profile": "CPU profile. You can specify the duration in the seconds GET parameter. After you get the profile file, use the go tool pprof command to investigate the profile.",
@@ -417,7 +423,9 @@ func indexTmplExecute(w io.Writer, profiles []profileEntry) error {
417423
</style>
418424
</head>
419425
<body>
420-
/debug/pprof/<br>
426+
/debug/pprof/
427+
<br>
428+
<p>Set debug=1 as a query parameter to export in legacy text format</p>
421429
<br>
422430
Types of profiles available:
423431
<table>

0 commit comments

Comments
 (0)