File tree Expand file tree Collapse file tree 2 files changed +5
-19
lines changed Expand file tree Collapse file tree 2 files changed +5
-19
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ Additionally fgprof supports the plain text format used by Brendan Gregg's [Flam
4848```
4949git clone https://github.com/brendangregg/FlameGraph
5050cd FlameGraph
51- curl -s 'localhost:6060/debug/fgprof?seconds=3' > fgprof.fold
52- ./flamegraph.pl fgprof.fold > fgprof.svg
51+ curl -s 'localhost:6060/debug/fgprof?seconds=3&format=folded ' > fgprof.folded
52+ ./flamegraph.pl fgprof.folded > fgprof.svg
5353```
5454
5555![ ] ( ./assets/fgprof_gregg.png )
Original file line number Diff line number Diff line change @@ -3,15 +3,13 @@ package fgprof
33import (
44 "fmt"
55 "net/http"
6- "strings"
76 "time"
87)
98
109// Handler returns an http handler that requires a "seconds" query argument
1110// and produces a profile over this duration. The optional "format" parameter
12- // controls if the output is written in Brendan Gregg's "folded" stack
13- // format, or Google's "pprof" format. If no "format" is given, the handler
14- // tries to guess the best format based on the http headers.
11+ // controls if the output is written in Google's "pprof" format (default) or
12+ // Brendan Gregg's "folded" stack format.
1513func Handler () http.Handler {
1614 return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
1715 var seconds int
@@ -22,23 +20,11 @@ func Handler() http.Handler {
2220
2321 format := Format (r .URL .Query ().Get ("format" ))
2422 if format == "" {
25- format = guessFormat ( r )
23+ format = FormatPprof
2624 }
2725
2826 stop := Start (w , format )
2927 defer stop ()
3028 time .Sleep (time .Duration (seconds ) * time .Second )
3129 })
3230}
33-
34- // guessFormat returns FormatPprof if it looks like pprof sent r, otherwise
35- // FormatFolded. It's not meant to be a perfect heuristic, but a nice
36- // convenience for users that don't want to specify the format explicitly.
37- func guessFormat (r * http.Request ) Format {
38- for _ , format := range r .Header ["Accept-Encoding" ] {
39- if strings .ToLower (format ) == "gzip" {
40- return FormatPprof
41- }
42- }
43- return FormatFolded
44- }
You can’t perform that action at this time.
0 commit comments