diff --git a/server/src/core/metrics.go b/server/src/core/metrics.go index 6c6b915..bb7a9a8 100644 --- a/server/src/core/metrics.go +++ b/server/src/core/metrics.go @@ -2,6 +2,7 @@ package core import ( "encoding/json" + "fmt" "net/http" "project/es" "project/metrics" @@ -13,7 +14,7 @@ import ( "github.com/zhengkai/zu" ) -func doMetrics(ab []byte, cached bool, r *http.Request, reqBytes int) { +func doMetrics(ab []byte, cached bool, r *http.Request, req *pb.Req) { rspBytes := len(ab) metrics.RspBytes(rspBytes) @@ -60,9 +61,10 @@ func doMetrics(ab []byte, cached bool, r *http.Request, reqBytes int) { Ip: sip, Model: o.Model, Key: key, - ReqBytes: uint32(reqBytes), + ReqBytes: uint32(len(req.Body)), RspBytes: uint32(rspBytes), Ts: zu.MS(), + Hash: fmt.Sprintf(`%x`, req.Hash()), } go es.Insert(d) } diff --git a/server/src/core/web.go b/server/src/core/web.go index 23a7943..c859c17 100644 --- a/server/src/core/web.go +++ b/server/src/core/web.go @@ -36,5 +36,5 @@ func (c *Core) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Header().Add(`Content-Type`, `application/json`) w.Write(ab) - go doMetrics(ab, cached, r, len(p.Body)) + go doMetrics(ab, cached, r, p) }