Repository: incubator-htrace Updated Branches: refs/heads/master feae543f3 -> daf3645d5
HTRACE-127. fix ./build/htrace dumpAll (cmccabe) Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/daf3645d Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/daf3645d Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/daf3645d Branch: refs/heads/master Commit: daf3645d55a57adf5333f6d8b98204f6a419a7f2 Parents: feae543 Author: Colin P. Mccabe <[email protected]> Authored: Mon Mar 2 14:00:27 2015 -0800 Committer: Colin P. Mccabe <[email protected]> Committed: Mon Mar 2 14:00:27 2015 -0800 ---------------------------------------------------------------------- htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/daf3645d/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go ---------------------------------------------------------------------- diff --git a/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go b/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go index ef7b43f..a38e314 100644 --- a/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go +++ b/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go @@ -263,8 +263,10 @@ func doDumpAll(hcl *htrace.Client, outPath string, lim int) error { if err != nil { return err } + w := bufio.NewWriter(file) defer func() { if file != nil { + w.Flush() file.Close() } }() @@ -280,15 +282,15 @@ func doDumpAll(hcl *htrace.Client, outPath string, lim int) error { if !channelOpen { break } - if err != nil { - _, err = fmt.Fprintf(file, "%s\n", span.ToJson()) + if err == nil { + _, err = fmt.Fprintf(w, "%s\n", span.ToJson()) } if *verbose { numSpans++ now := time.Now() if !now.Before(nextLogTime) { nextLogTime = now.Add(time.Second * 5) - fmt.Printf("wrote %d span(s)...\n", numSpans) + fmt.Printf("received %d span(s)...\n", numSpans) } } } @@ -298,6 +300,10 @@ func doDumpAll(hcl *htrace.Client, outPath string, lim int) error { if dumpErr != nil { return errors.New(fmt.Sprintf("Dump error %s", dumpErr.Error())) } + err = w.Flush() + if err != nil { + return err + } err = file.Close() file = nil if err != nil {
