mirror of
https://github.com/zhengkai/orca.git
synced 2026-02-04 15:02:26 +08:00
fix es hash
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user