Browse Source

Add unix timestamp instead of Now

Oz Tiram 5 years ago
parent
commit
2d40ecf933
1 changed files with 4 additions and 1 deletions
  1. 4 1
      gupta.go

+ 4 - 1
gupta.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"strconv"
 	"strings"
+	"time"
 )
 
 const version = "0.0.1"
@@ -29,7 +30,9 @@ type GuptaReport struct {
 // usually you'd want a g GuptaReport reciever here ...
 // but than you could now check for the object properties ...
 func (g *GuptaReport) MarshalJSON() ([]byte, error) {
-	report := []byte("{\"timestamp\": \"now\", \"metrics\": [")
+	t := time.Now()
+	report := []byte(fmt.Sprintf("{\"timestamp\": \"%d\", \"metrics\": [",
+		t.Unix()))
 	if g.CPUUsage != nil {
 		usage, _ := json.Marshal(g.CPUUsage)
 		report = append(report, usage...)