From b1f64df2275a1c18029c5f080d43818cef9b0017 Mon Sep 17 00:00:00 2001 From: Zheng Kai Date: Tue, 13 Jun 2023 16:43:09 +0800 Subject: [PATCH] fix es hash --- server/src/core/metrics.go | 6 ++++-- server/src/core/web.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) 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) }