-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
decompressor library: add stats to zlib library #11782
Conversation
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
@rojkov we saw some decompression errors, and felt that it warranted adding stats here. Let me know what you think! |
Signed-off-by: Jose Nino <[email protected]>
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.
Thank you! That's a good addition. I might need a similar patch for the compressor part.
@@ -94,7 +94,7 @@ class DecompressorFilterConfig { | |||
Compression::Decompressor::DecompressorFactoryPtr decompressor_factory); | |||
|
|||
Compression::Decompressor::DecompressorPtr makeDecompressor() { | |||
return decompressor_factory_->createDecompressor(); | |||
return decompressor_factory_->createDecompressor(stats_prefix_ + "decompressor_library"); |
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.
Can we make this stat prefix be a part of decompressor_factory_
's state? So that this string concatenation would happen only once at Envoy's start rather than for every stream creation.
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.
I debated this back and forth because I am not sure if we would have a place where we would want each decompressor created by the same factory to have different strings.
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.
lets just do it the way you suggest. Having the string concatenation in the hot path seems like a bad price to pay for the niche ability to configure stats trees differently for individual decompressors.
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.
nvm all of the above. I now do understand what you mean. Let me know if what I have pushed is not it.
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.
That's definitely better. Though I was thinking about changing the meaning of DecompressorFactory::statsPrefix()
. Instead of returning .gzip
it could return the full root stats prefix since we create a factory per DecompressionFilterConfig
anyway.
Then DecompressorFilterConfig::stats_prefix_
wouldn't be needed and DecompressorFactory::createDecompressor()
would retain its current signature.
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.
I didn’t want to do that because I don’t want the filter stats to have the decompressor_library prefix. To me the public statsPrefix function is for a consumer to use. And the argument in createDeconoressor is what the consumer wants to ultimately root the decompressor at.
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.
Alright, fair enough.
"zlib decompression error: {}, msg: {}. Error codes are defined in " | ||
"https://www.zlib.net/manual.html", | ||
result, zstream_ptr_->msg); | ||
stats_.decompression_error_.inc(); |
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.
Is it enough for your use case not to differentiate errors by their type?
I'm thinking that it might be useful to check the stats and see what's wrong immediately (e.g. is it Z_DATA_ERROR
or Z_MEM_ERROR
?) instead of increasing log verbosity to trace
.
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.
The issue is that even a Z_DATA_ERROR
can have dozens of different reasons for occurring, so you would still need to look at logs to get at the heart of it. However, I do think your idea of differentiating based on returned error code is good. I'll make the change.
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
@rojkov updated! I am going to be taking time off the rest of this week, but @rebello95 will take a look at this PR after you give it another look and proceed accordingly. |
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
This reverts commit bc382b0. Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
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.
Looks good! Just a couple of questions.
@@ -153,4 +155,107 @@ TEST_P(DecompressorIntegrationTest, BidirectionalDecompression) { | |||
uncompressed_response_length); | |||
} | |||
|
|||
/** | |||
* Exercises gzip decompression bidirectionally with default configuration. |
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.
I'd replace "default configuration" with something like "configuration using wrong value for Zlib's windowBits".
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.
bad copy paste, sorry!
ASSERT_TRUE(upstream_request_->waitForEndStream(*dispatcher_)); | ||
|
||
EXPECT_TRUE(upstream_request_->complete()); | ||
TestUtility::headerMapEqualIgnoreOrder( |
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.
Shouldn't we set expectations for these equality checks? Looks like the return value of the check is simply ignored.
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.
yeah, they were bad before. Thanks for noticing, updated!
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
@rojkov updated! |
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.
Probably one comment line needs polishing, but the rest looks good to me.
@@ -49,7 +69,19 @@ class ZlibDecompressorImpl : public Zlib::Base, | |||
int decompression_error_{0}; | |||
|
|||
private: | |||
// TODO: clean up friend class. This is here to allow coverage of chargeErrorStats as it isn't |
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.
Nit: you may want to have TODO(junr03)
in this line.
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.
I like leaving todos I don't intend to do right away without a username that way it doesn't dissuade others to fix todos they find.
Signed-off-by: Jose Nino <[email protected]>
@dio this is ready for a final pass, do you mind taking it? |
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.
Thank you! This is good! Sorry for the late reply!
Http::TestRequestHeaderMapImpl headers_before_filter{ | ||
{"cache-control", fmt::format("{}, {}", Http::CustomHeaders::get().CacheControlValues.NoCache, | ||
Http::CustomHeaders::get().CacheControlValues.NoTransform)}, | ||
{"content-encoding", "mock"}, | ||
{"content-length", "256"}}; | ||
std::unique_ptr<Http::RequestOrResponseHeaderMap> headers_after_filter = | ||
doHeaders(headers_before_filter, false /* end_stream */); | ||
TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); |
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.
Just curious. So here, we don't expect headers_before_filter
to be the same as *headers_after_filter
since there is no EXPECT_THAT()
replacement here.
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
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.
Thank you!
Description: Pulls in multiple fixes committed to upstream Envoy. - Update for resolution to TLSContext crash: envoyproxy/envoy#10030 - Fixes for 32 bit archs: envoyproxy/envoy#11726 - Fix for missing posix call on Android: envoyproxy/envoy#12081 - Additional zlib stats: envoyproxy/envoy#11782 Signed-off-by: Mike Schore <[email protected]>
This adds decompressor error stats to the zlib decompressor library. This introduces a lot of boilerplate but will make it easier to continue to add stats in the future. Additionally, the compressor library can use the same pattern. Risk Level: Low. Testing: Updated. Docs Changes: Added. Signed-off-by: Jose Nino <[email protected]> Signed-off-by: scheler <[email protected]>
Description: Pulls in multiple fixes committed to upstream Envoy. - Update for resolution to TLSContext crash: #10030 - Fixes for 32 bit archs: #11726 - Fix for missing posix call on Android: #12081 - Additional zlib stats: #11782 Signed-off-by: Mike Schore <[email protected]> Signed-off-by: JP Simard <[email protected]>
Description: Pulls in multiple fixes committed to upstream Envoy. - Update for resolution to TLSContext crash: #10030 - Fixes for 32 bit archs: #11726 - Fix for missing posix call on Android: #12081 - Additional zlib stats: #11782 Signed-off-by: Mike Schore <[email protected]> Signed-off-by: JP Simard <[email protected]>
Commit Message: adding decompressor error stats to the zlib decompressor library.
Additional Description: lots of boilerplate, but will make it easier to continue to add stats in the future. Additionally, the compressor library can use the same pattern.
Risk Level: low
Testing: updated tests
Docs Changes: added documentation.
Signed-off-by: Jose Nino [email protected]