瀏覽代碼

Add unix timestamp instead of Now

Oz Tiram 5 年之前
父節點
當前提交
2d40ecf933
共有 1 個文件被更改,包括 4 次插入1 次删除
  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...)