diff --git a/README.md b/README.md index 25fa1a3..fe0c0a2 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ Additionally fgprof supports the plain text format used by Brendan Gregg's [Flam ``` git clone https://github.com/brendangregg/FlameGraph cd FlameGraph -curl -s 'localhost:6060/debug/fgprof?seconds=3' > fgprof.fold -./flamegraph.pl fgprof.fold > fgprof.svg +curl -s 'localhost:6060/debug/fgprof?seconds=3&format=folded' > fgprof.folded +./flamegraph.pl fgprof.folded > fgprof.svg ``` ![](./assets/fgprof_gregg.png) diff --git a/handler.go b/handler.go index 106e731..93d9663 100644 --- a/handler.go +++ b/handler.go @@ -3,15 +3,13 @@ package fgprof import ( "fmt" "net/http" - "strings" "time" ) // Handler returns an http handler that requires a "seconds" query argument // and produces a profile over this duration. The optional "format" parameter -// controls if the output is written in Brendan Gregg's "folded" stack -// format, or Google's "pprof" format. If no "format" is given, the handler -// tries to guess the best format based on the http headers. +// controls if the output is written in Google's "pprof" format (default) or +// Brendan Gregg's "folded" stack format. func Handler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var seconds int @@ -22,7 +20,7 @@ func Handler() http.Handler { format := Format(r.URL.Query().Get("format")) if format == "" { - format = guessFormat(r) + format = FormatPprof } stop := Start(w, format) @@ -30,15 +28,3 @@ func Handler() http.Handler { time.Sleep(time.Duration(seconds) * time.Second) }) } - -// guessFormat returns FormatPprof if it looks like pprof sent r, otherwise -// FormatFolded. It's not meant to be a perfect heuristic, but a nice -// convenience for users that don't want to specify the format explicitly. -func guessFormat(r *http.Request) Format { - for _, format := range r.Header["Accept-Encoding"] { - if strings.ToLower(format) == "gzip" { - return FormatPprof - } - } - return FormatFolded -}