stackView generates the flamegraph view.
(w http.ResponseWriter, req *http.Request)
| 24 | |
| 25 | // stackView generates the flamegraph view. |
| 26 | func (ui *webInterface) stackView(w http.ResponseWriter, req *http.Request) { |
| 27 | // Get all data in a report. |
| 28 | rpt, errList := ui.makeReport(w, req, []string{"svg"}, func(cfg *config) { |
| 29 | cfg.CallTree = true |
| 30 | cfg.Trim = false |
| 31 | if cfg.Granularity == "" { |
| 32 | cfg.Granularity = "filefunctions" |
| 33 | } |
| 34 | }) |
| 35 | if rpt == nil { |
| 36 | return // error already reported |
| 37 | } |
| 38 | |
| 39 | // Make stack data and generate corresponding JSON. |
| 40 | stacks := rpt.Stacks() |
| 41 | b, err := json.Marshal(stacks) |
| 42 | if err != nil { |
| 43 | http.Error(w, "error serializing stacks for flame graph", |
| 44 | http.StatusInternalServerError) |
| 45 | ui.options.UI.PrintErr(err) |
| 46 | return |
| 47 | } |
| 48 | |
| 49 | nodes := make([]string, len(stacks.Sources)) |
| 50 | for i, src := range stacks.Sources { |
| 51 | nodes[i] = src.FullName |
| 52 | } |
| 53 | nodes[0] = "" // root is not a real node |
| 54 | |
| 55 | ui.render(w, req, "stacks", rpt, errList, stacks.Legend(), webArgs{ |
| 56 | Stacks: template.JS(b), |
| 57 | Nodes: nodes, |
| 58 | UnitDefs: measurement.UnitTypes, |
| 59 | }) |
| 60 | } |
nothing calls this directly
no test coverage detected