decompressor library: add stats to zlib library#11782
decompressor library: add stats to zlib library#11782dio merged 23 commits intoenvoyproxy:masterfrom junr03:decompressor-stats
Conversation
Signed-off-by: Jose Nino <jnino@lyft.com>
|
@rojkov we saw some decompression errors, and felt that it warranted adding stats here. Let me know what you think! |
rojkov
left a comment
There was a problem hiding this comment.
Thank you! That's a good addition. I might need a similar patch for the compressor part.
|
|
||
| Compression::Decompressor::DecompressorPtr makeDecompressor() { | ||
| return decompressor_factory_->createDecompressor(); | ||
| return decompressor_factory_->createDecompressor(stats_prefix_ + "decompressor_library"); |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
| "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.
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.
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 <jnino@lyft.com>
|
@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 <jnino@lyft.com>
This reverts commit bc382b0. Signed-off-by: Jose Nino <jnino@lyft.com>
rojkov
left a comment
There was a problem hiding this comment.
Looks good! Just a couple of questions.
| } | ||
|
|
||
| /** | ||
| * Exercises gzip decompression bidirectionally with default configuration. |
There was a problem hiding this comment.
I'd replace "default configuration" with something like "configuration using wrong value for Zlib's windowBits".
| ASSERT_TRUE(upstream_request_->waitForEndStream(*dispatcher_)); | ||
|
|
||
| EXPECT_TRUE(upstream_request_->complete()); | ||
| TestUtility::headerMapEqualIgnoreOrder( |
There was a problem hiding this comment.
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.
yeah, they were bad before. Thanks for noticing, updated!
Signed-off-by: Jose Nino <jnino@lyft.com>
|
@rojkov updated! |
rojkov
left a comment
There was a problem hiding this comment.
Probably one comment line needs polishing, but the rest looks good to me.
| 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.
Nit: you may want to have TODO(junr03) in this line.
There was a problem hiding this comment.
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 <jnino@lyft.com>
|
@dio this is ready for a final pass, do you mind taking it? |
dio
left a comment
There was a problem hiding this comment.
Thank you! This is good! Sorry for the late reply!
| {"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.
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 <jnino@lyft.com>
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 <mike.schore@gmail.com>
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 <jnino@lyft.com> Signed-off-by: scheler <santosh.cheler@appdynamics.com>
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 <mike.schore@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
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 <mike.schore@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
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 jnino@lyft.com