Skip to content

Commit

Permalink
adjust metrics output formats to normalize on nanoseconds since epoch…
Browse files Browse the repository at this point in the history
… for time and nanoseconds for durations
  • Loading branch information
josephcopenhaver committed Aug 8, 2024
1 parent b72174b commit f96167c
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 226 deletions.
95 changes: 64 additions & 31 deletions docs/metrics.md

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions loadtester/csv_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"io"
"os"
"strconv"
"sync"
"time"
)
Expand Down Expand Up @@ -57,10 +58,6 @@ func (lt *Loadtest) writeOutputCsvConfigComment(w io.Writer) error {
return err
}

if _, err := w.Write([]byte("\n")); err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -170,7 +167,7 @@ func (lt *Loadtest) writeOutputCsvFooterAndClose(csvFile *os.File) {
return
}

_, cd.writeErr = csvFile.Write([]byte("\n# {\"done\":{\"end_time\":\"" + timeToString(time.Now()) + "\"}}\n"))
_, cd.writeErr = csvFile.Write([]byte("# {\"done\":{\"end_time\":\"" + timeToString(time.Now()) + "\"}}"))
}

//
Expand All @@ -180,3 +177,11 @@ func (lt *Loadtest) writeOutputCsvFooterAndClose(csvFile *os.File) {
func timeToString(t time.Time) string {
return t.UTC().Format(time.RFC3339Nano)
}

func timeToUnixNanoString(t time.Time) string {
return strconv.FormatInt(t.UnixNano(), 10)
}

func durationToNanoString(d time.Duration) string {
return strconv.FormatInt(d.Nanoseconds(), 10)
}
Loading

0 comments on commit f96167c

Please sign in to comment.