Browse Source

fix: viewer function receiving null node list (#266)

Martin Spier 7 years ago
parent
commit
77ec2c44fb
1 changed files with 4 additions and 0 deletions
  1. 4
    0
      internal/driver/flamegraph.go

+ 4
- 0
internal/driver/flamegraph.go View File

47
 	var nodes []*treeNode
47
 	var nodes []*treeNode
48
 	nroots := 0
48
 	nroots := 0
49
 	rootValue := int64(0)
49
 	rootValue := int64(0)
50
+	nodeArr := []string{}
50
 	nodeMap := map[*graph.Node]*treeNode{}
51
 	nodeMap := map[*graph.Node]*treeNode{}
51
 	// Make all nodes and the map, collect the roots.
52
 	// Make all nodes and the map, collect the roots.
52
 	for _, n := range g.Nodes {
53
 	for _, n := range g.Nodes {
64
 			rootValue += v
65
 			rootValue += v
65
 		}
66
 		}
66
 		nodeMap[n] = node
67
 		nodeMap[n] = node
68
+		// Get all node names into an array.
69
+		nodeArr = append(nodeArr, n.Info.Name)
67
 	}
70
 	}
68
 	// Populate the child links.
71
 	// Populate the child links.
69
 	for _, n := range g.Nodes {
72
 	for _, n := range g.Nodes {
91
 
94
 
92
 	ui.render(w, "/flamegraph", "flamegraph", rpt, errList, config.Labels, webArgs{
95
 	ui.render(w, "/flamegraph", "flamegraph", rpt, errList, config.Labels, webArgs{
93
 		FlameGraph: template.JS(b),
96
 		FlameGraph: template.JS(b),
97
+		Nodes:      nodeArr,
94
 	})
98
 	})
95
 }
99
 }