mirror of https://github.com/grpc/grpc-go.git
server: populate WireLength on stats.InPayload for unary RPCs (#2932)
Fixes #2692 which was incompletely fixed by #2711. Also adds updates stats/stat_test.go to sanity check WireLength.
This commit is contained in:
parent
61f27c1415
commit
b5748caae7
|
@ -971,10 +971,11 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
|||
}
|
||||
if sh != nil {
|
||||
sh.HandleRPC(stream.Context(), &stats.InPayload{
|
||||
RecvTime: time.Now(),
|
||||
Payload: v,
|
||||
Data: d,
|
||||
Length: len(d),
|
||||
RecvTime: time.Now(),
|
||||
Payload: v,
|
||||
WireLength: payInfo.wireLength,
|
||||
Data: d,
|
||||
Length: len(d),
|
||||
})
|
||||
}
|
||||
if binlog != nil {
|
||||
|
|
|
@ -511,7 +511,12 @@ func checkInPayload(t *testing.T, d *gotData, e *expectedData) {
|
|||
t.Fatalf("st.Lenght = %v, want %v", st.Length, len(b))
|
||||
}
|
||||
}
|
||||
// TODO check WireLength and ReceivedTime.
|
||||
// Below are sanity checks that WireLength and RecvTime are populated.
|
||||
// TODO: check values of WireLength and RecvTime.
|
||||
if len(st.Data) > 0 && st.WireLength == 0 {
|
||||
t.Fatalf("st.WireLength = %v with non-empty data, want <non-zero>",
|
||||
st.WireLength)
|
||||
}
|
||||
if st.RecvTime.IsZero() {
|
||||
t.Fatalf("st.ReceivedTime = %v, want <non-zero>", st.RecvTime)
|
||||
}
|
||||
|
@ -603,7 +608,12 @@ func checkOutPayload(t *testing.T, d *gotData, e *expectedData) {
|
|||
t.Fatalf("st.Lenght = %v, want %v", st.Length, len(b))
|
||||
}
|
||||
}
|
||||
// TODO check WireLength and ReceivedTime.
|
||||
// Below are sanity checks that WireLength and SentTime are populated.
|
||||
// TODO: check values of WireLength and SentTime.
|
||||
if len(st.Data) > 0 && st.WireLength == 0 {
|
||||
t.Fatalf("st.WireLength = %v with non-empty data, want <non-zero>",
|
||||
st.WireLength)
|
||||
}
|
||||
if st.SentTime.IsZero() {
|
||||
t.Fatalf("st.SentTime = %v, want <non-zero>", st.SentTime)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue