-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stats: set response compression codec on stats.InHeader and stats.OutHeader #3390
stats: set response compression codec on stats.InHeader and stats.OutHeader #3390
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix. Can you change the tests to cover the new field as well? The following diff should work.
Also, I think you might have missed http2_server.go
. The test hopefully should catch that.
Thanks!
diff --git a/stats/stats_test.go b/stats/stats_test.go
index ff16c182..d047d48b 100644
--- a/stats/stats_test.go
+++ b/stats/stats_test.go
@@ -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 {
0bbce81
to
dd7ef89
Compare
Thank you for the feedback, @menghanl. You were right about the tests and missed case. I have updated both, rebased on latest, and updated the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the changes!
Currently, the request compression is recorded (on
stats.OutHeader
client-side andstats.InHeader
server-side), but the response compression is never recorded. Although these compression codecs are often the same, the gRPC compression specification (https://github.com/grpc/grpc/blob/master/doc/compression.md) states that it's valid for them to be different.stats.InHeader
client-side andstats.OutHeader
server-side).Compression
andHeader
) above the commentThe following fields are valid only if Client is true.
because they are now both valid on the server-side and client-side.