Merge branch 'master' into vtrace
diff --git a/vtrace/format.go b/vtrace/format.go
index 8de9bdc..a6bc9c4 100644
--- a/vtrace/format.go
+++ b/vtrace/format.go
@@ -15,11 +15,11 @@
 
 const indentStep = "    "
 
-type children []*node
+type children []*Node
 
 // children implements sort.Interface
 func (c children) Len() int           { return len(c) }
-func (c children) Less(i, j int) bool { return c[i].span.Start.Before(c[j].span.Start) }
+func (c children) Less(i, j int) bool { return c[i].Span.Start.Before(c[j].Span.Start) }
 func (c children) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }
 
 type annotations []Annotation
@@ -29,18 +29,18 @@
 func (a annotations) Less(i, j int) bool { return a[i].When.Before(a[j].When) }
 func (a annotations) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
 
-type node struct {
-	span     *SpanRecord
-	children children
+type Node struct {
+	Span *SpanRecord
+	Children []*Node
 }
 
 // TODO(mattr): It is useful in general to make a tree of spans
 // for analysis as well as formatting.  This interface should
 // be cleaned up and exported.
-func buildTree(trace *TraceRecord) *node {
-	var root *node
+func BuildTree(trace *TraceRecord) *Node {
+	var root *Node
 	var earliestTime time.Time
-	nodes := make(map[uniqueid.Id]*node, len(trace.Spans))
+	nodes := make(map[uniqueid.Id]*Node, len(trace.Spans))
 
 	for i := range trace.Spans {
 		span := &trace.Spans[i]
@@ -50,38 +50,38 @@
 
 		n := nodes[span.Id]
 		if n == nil {
-			n = &node{}
+			n = &Node{}
 			nodes[span.Id] = n
 		}
 
-		n.span = span
+		n.Span = span
 
 		if span.Parent == trace.Id {
 			root = n
 		} else {
 			p := nodes[span.Parent]
 			if p == nil {
-				p = &node{}
+				p = &Node{}
 				nodes[span.Parent] = p
 			}
-			p.children = append(p.children, n)
+			p.Children = append(p.Children, n)
 		}
 	}
 
 	// Sort the children of each node in start-time order, and the
 	// annotation in time-order.
 	for _, node := range nodes {
-		sort.Sort(node.children)
-		if node.span != nil {
-			sort.Sort(annotations(node.span.Annotations))
+		sort.Sort(children(node.Children))
+		if node.Span != nil {
+			sort.Sort(annotations(node.Span.Annotations))
 		}
 	}
 
 	// If we didn't find the root span of the trace
 	// create a stand-in.
 	if root == nil {
-		root = &node{
-			span: &SpanRecord{
+		root = &Node{
+			Span: &SpanRecord{
 				Name:  "Missing Root Span",
 				Start: earliestTime,
 			},
@@ -92,10 +92,10 @@
 	// in the tree.  We invent fake "missing" spans to represent
 	// (perhaps several) layers of missing spans.  Then we add these as
 	// children of the root.
-	var missing []*node
+	var missing []*Node
 	for _, n := range nodes {
-		if n.span == nil {
-			n.span = &SpanRecord{
+		if n.Span == nil {
+			n.Span = &SpanRecord{
 				Name: "Missing Data",
 			}
 			missing = append(missing, n)
@@ -103,7 +103,7 @@
 	}
 
 	if len(missing) > 0 {
-		root.children = append(root.children, missing...)
+		root.Children = append(root.Children, missing...)
 	}
 
 	return root
@@ -116,20 +116,20 @@
 	return when.Sub(start).String()
 }
 
-func formatNode(w io.Writer, n *node, traceStart time.Time, indent string) {
+func formatNode(w io.Writer, n *Node, traceStart time.Time, indent string) {
 	fmt.Fprintf(w, "%sSpan - %s [id: %x parent %x] (%s, %s: %s)\n",
 		indent,
-		n.span.Name,
-		n.span.Id[12:],
-		n.span.Parent[12:],
-		formatDelta(n.span.Start, traceStart),
-		formatDelta(n.span.End, traceStart),
-		formatDelta(n.span.End, n.span.Start))
+		n.Span.Name,
+		n.Span.Id[12:],
+		n.Span.Parent[12:],
+		formatDelta(n.Span.Start, traceStart),
+		formatDelta(n.Span.End, traceStart),
+		formatDelta(n.Span.End, n.Span.Start))
 	indent += indentStep
-	for _, a := range n.span.Annotations {
+	for _, a := range n.Span.Annotations {
 		fmt.Fprintf(w, "%s@%s %s\n", indent, formatDelta(a.When, traceStart), a.Message)
 	}
-	for _, c := range n.children {
+	for _, c := range n.Children {
 		formatNode(w, c, traceStart, indent)
 	}
 }
@@ -148,13 +148,13 @@
 // given writer.  Times will be formatted according to the given
 // location, if loc is nil local times will be used.
 func FormatTrace(w io.Writer, record *TraceRecord, loc *time.Location) {
-	if root := buildTree(record); root != nil {
+	if root := BuildTree(record); root != nil {
 		fmt.Fprintf(w, "Trace - %s (%s, %s)\n",
 			record.Id,
-			formatTime(root.span.Start, loc),
-			formatTime(root.span.End, loc))
-		for _, c := range root.children {
-			formatNode(w, c, root.span.Start, indentStep)
+			formatTime(root.Span.Start, loc),
+			formatTime(root.Span.End, loc))
+		for _, c := range root.Children {
+			formatNode(w, c, root.Span.Start, indentStep)
 		}
 	}
 }