fix es hash

This commit is contained in:
Zheng Kai
2023-06-13 16:43:09 +08:00
parent f815cc68e6
commit b1f64df227
2 changed files with 5 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package core
import ( import (
"encoding/json" "encoding/json"
"fmt"
"net/http" "net/http"
"project/es" "project/es"
"project/metrics" "project/metrics"
@@ -13,7 +14,7 @@ import (
"github.com/zhengkai/zu" "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) rspBytes := len(ab)
metrics.RspBytes(rspBytes) metrics.RspBytes(rspBytes)
@@ -60,9 +61,10 @@ func doMetrics(ab []byte, cached bool, r *http.Request, reqBytes int) {
Ip: sip, Ip: sip,
Model: o.Model, Model: o.Model,
Key: key, Key: key,
ReqBytes: uint32(reqBytes), ReqBytes: uint32(len(req.Body)),
RspBytes: uint32(rspBytes), RspBytes: uint32(rspBytes),
Ts: zu.MS(), Ts: zu.MS(),
Hash: fmt.Sprintf(`%x`, req.Hash()),
} }
go es.Insert(d) go es.Insert(d)
} }

View File

@@ -36,5 +36,5 @@ func (c *Core) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Add(`Content-Type`, `application/json`) w.Header().Add(`Content-Type`, `application/json`)
w.Write(ab) w.Write(ab)
go doMetrics(ab, cached, r, len(p.Body)) go doMetrics(ab, cached, r, p)
} }