stats: set response compression codec on stats.InHeader and stats.OutHeader (#3390)
This commit is contained in:
@ -297,6 +297,7 @@ func (ht *serverHandlerTransport) WriteHeader(s *Stream, md metadata.MD) error {
|
||||
// No WireLength field is set here.
|
||||
ht.stats.HandleRPC(s.Context(), &stats.OutHeader{
|
||||
Header: md.Copy(),
|
||||
Compression: s.sendCompress,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1198,6 +1198,7 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
|
||||
Client: true,
|
||||
WireLength: int(frame.Header().Length),
|
||||
Header: s.header.Copy(),
|
||||
Compression: s.recvCompress,
|
||||
}
|
||||
t.statsHandler.HandleRPC(s.ctx, inHeader)
|
||||
} else {
|
||||
|
@ -817,6 +817,7 @@ func (t *http2Server) writeHeaderLocked(s *Stream) error {
|
||||
// No WireLength field is set here.
|
||||
outHeader := &stats.OutHeader{
|
||||
Header: s.header.Copy(),
|
||||
Compression: s.sendCompress,
|
||||
}
|
||||
t.stats.HandleRPC(s.Context(), outHeader)
|
||||
}
|
||||
|
@ -81,6 +81,10 @@ type InHeader struct {
|
||||
Client bool
|
||||
// WireLength is the wire length of header.
|
||||
WireLength int
|
||||
// Compression is the compression algorithm used for the RPC.
|
||||
Compression string
|
||||
// Header contains the header metadata received.
|
||||
Header metadata.MD
|
||||
|
||||
// The following fields are valid only if Client is false.
|
||||
// FullMethod is the full RPC method string, i.e., /package.service/method.
|
||||
@ -89,10 +93,6 @@ type InHeader struct {
|
||||
RemoteAddr net.Addr
|
||||
// LocalAddr is the local address of the corresponding connection.
|
||||
LocalAddr net.Addr
|
||||
// Compression is the compression algorithm used for the RPC.
|
||||
Compression string
|
||||
// Header contains the header metadata received.
|
||||
Header metadata.MD
|
||||
}
|
||||
|
||||
// IsClient indicates if the stats information is from client side.
|
||||
@ -141,6 +141,10 @@ func (s *OutPayload) isRPCStats() {}
|
||||
type OutHeader struct {
|
||||
// Client is true if this OutHeader is from client side.
|
||||
Client bool
|
||||
// Compression is the compression algorithm used for the RPC.
|
||||
Compression string
|
||||
// Header contains the header metadata sent.
|
||||
Header metadata.MD
|
||||
|
||||
// The following fields are valid only if Client is true.
|
||||
// FullMethod is the full RPC method string, i.e., /package.service/method.
|
||||
@ -149,10 +153,6 @@ type OutHeader struct {
|
||||
RemoteAddr net.Addr
|
||||
// LocalAddr is the local address of the corresponding connection.
|
||||
LocalAddr net.Addr
|
||||
// Compression is the compression algorithm used for the RPC.
|
||||
Compression string
|
||||
// Header contains the header metadata sent.
|
||||
Header metadata.MD
|
||||
}
|
||||
|
||||
// IsClient indicates if this stats information is from client side.
|
||||
|
@ -446,6 +446,9 @@ func checkInHeader(t *testing.T, d *gotData, e *expectedData) {
|
||||
if d.ctx == nil {
|
||||
t.Fatalf("d.ctx = nil, want <non-nil>")
|
||||
}
|
||||
if st.Compression != e.compression {
|
||||
t.Fatalf("st.Compression = %v, want %v", st.Compression, e.compression)
|
||||
}
|
||||
if d.client {
|
||||
// additional headers might be injected so instead of testing equality, test that all the
|
||||
// expected headers keys have the expected header values.
|
||||
@ -461,9 +464,6 @@ func checkInHeader(t *testing.T, d *gotData, e *expectedData) {
|
||||
if st.LocalAddr.String() != e.serverAddr {
|
||||
t.Fatalf("st.LocalAddr = %v, want %v", st.LocalAddr, e.serverAddr)
|
||||
}
|
||||
if st.Compression != e.compression {
|
||||
t.Fatalf("st.Compression = %v, want %v", st.Compression, e.compression)
|
||||
}
|
||||
// additional headers might be injected so instead of testing equality, test that all the
|
||||
// expected headers keys have the expected header values.
|
||||
for key := range testMetadata {
|
||||
@ -575,6 +575,9 @@ func checkOutHeader(t *testing.T, d *gotData, e *expectedData) {
|
||||
if d.ctx == nil {
|
||||
t.Fatalf("d.ctx = nil, want <non-nil>")
|
||||
}
|
||||
if st.Compression != e.compression {
|
||||
t.Fatalf("st.Compression = %v, want %v", st.Compression, e.compression)
|
||||
}
|
||||
if d.client {
|
||||
if st.FullMethod != e.method {
|
||||
t.Fatalf("st.FullMethod = %s, want %v", st.FullMethod, e.method)
|
||||
@ -582,9 +585,6 @@ func checkOutHeader(t *testing.T, d *gotData, e *expectedData) {
|
||||
if st.RemoteAddr.String() != e.serverAddr {
|
||||
t.Fatalf("st.RemoteAddr = %v, want %v", st.RemoteAddr, e.serverAddr)
|
||||
}
|
||||
if st.Compression != e.compression {
|
||||
t.Fatalf("st.Compression = %v, want %v", st.Compression, e.compression)
|
||||
}
|
||||
// additional headers might be injected so instead of testing equality, test that all the
|
||||
// expected headers keys have the expected header values.
|
||||
for key := range testMetadata {
|
||||
|
Reference in New Issue
Block a user