Skip to content

Conversation

@ArthurSens
Copy link
Member

Description

This is an alternative PR to #12825.

I'm taking all the commits from that PR and adding the feature gate on the client side, as requested by reviews. The server behavior of peeking into the initial bytes to identify the encoding is kept :)

If you've reviewed the previous PR, you can just review the latest commit!

Link to tracking issue

Fixes #10584

@ArthurSens ArthurSens requested a review from a team as a code owner April 22, 2025 21:30
@ArthurSens ArthurSens requested a review from codeboten April 22, 2025 21:30
@ArthurSens
Copy link
Member Author

Hey @skandragon, I took the liberty of continuing your PR just because we're blocked in developing the prometheusremotewritereceiver. I hope that's okay!

cc @bogdandrutu @jade-guiton-dd @perebaj

@codecov
Copy link

codecov bot commented Apr 22, 2025

Codecov Report

Attention: Patch coverage is 70.58824% with 20 lines in your changes missing coverage. Please review.

Project coverage is 91.64%. Comparing base (84888ad) to head (590d018).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
config/confighttp/compressor.go 61.29% 9 Missing and 3 partials ⚠️
config/confighttp/compression.go 73.33% 5 Missing and 3 partials ⚠️

❌ Your patch status has failed because the patch coverage (70.58%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12911      +/-   ##
==========================================
- Coverage   91.70%   91.64%   -0.06%     
==========================================
  Files         503      503              
  Lines       27568    27634      +66     
==========================================
+ Hits        25280    25326      +46     
- Misses       1808     1822      +14     
- Partials      480      486       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +26 to +29
If the feature-gate "confighttp.framedSnappy" is enabled, you'll see new behavior for both client and server:
- Client compression type "snappy" will now compress to the "block" variant of snappy
instead of "framed". Client compression type "x-snappy-framed" will now compress to the "framed" variant of snappy.
- Servers will accept both "snappy" and "x-snappy-framed" as valid content-encodings.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not clear about when gate is disabled (default).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first paragraph of the Subtext explains what happens when the gate is disabled. Could you suggest a better version of those paragraphs?

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, would like @jade-guiton-dd to review as well.

Copy link
Contributor

@jade-guiton-dd jade-guiton-dd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few nitpicks and questions.

After reviewing the docs for both formats, the protocol-detection and compression logic looks sound to me.

@ArthurSens ArthurSens force-pushed the fix-snappy branch 2 times, most recently from 0a145dc to afb1474 Compare April 28, 2025 18:59
@skandragon
Copy link
Contributor

Hey @skandragon, I took the liberty of continuing your PR just because we're blocked in developing the prometheusremotewritereceiver. I hope that's okay!

Not only is it OK, it is amazing :)

Thank you.

@ArthurSens
Copy link
Member Author

Urgh, I'm struggling a bit with the tests now... It looks like there's some flakyness that I can't understand why it's happening.

https://www.loom.com/share/238df1a06cd642cf9578a2fdf5683c8b

@jade-guiton-dd
Copy link
Contributor

jade-guiton-dd commented Apr 29, 2025

I also get that error when running TestHTTPContentDecompressionHandler alone without commenting the other test cases FWIW

@perebaj
Copy link
Contributor

perebaj commented Apr 29, 2025

Urgh, I'm struggling a bit with the tests now... It looks like there's some flakyness that I can't understand why it's happening.

https://www.loom.com/share/238df1a06cd642cf9578a2fdf5683c8b

@ArthurSens, this command already save my life for this type of flaky tests. Maybe could be helpful. You can pass to it just the files that you want to validate..

go run go.uber.org/nilaway/cmd/nilaway -test=false -include-pkgs="" -exclude-errors-in-files=mock_ ./...

More: https://github.com/uber-go/nilaway

@jade-guiton-dd
Copy link
Contributor

I did a bit of debugging: the crash in the tests occurs because of the "caching" of availableDecoders that I suggested. The first few test cases in TestHTTPContentDecompressionHandler run httpContentDecompressor with the feature gate disabled, so availableDecoders is created without the decoder for x-snappy-framed. Later test cases enable the feature gate, but because availableDecoders isn't recreated, and because there is no check in httpContentDecompressor to check that the requested decoder actually exists (there really should be one, but that's a different issue), we end up with a nil pointer in decompressor.decoders["x-snappy-framed"], which causes a panic when it's called.

I don't think the state of feature gates should change during a normal run of the Collector, so I think this is a test-only issue.

A dirty solution could be to manually set availableDecoders back to nil before each test case, but I think my preferred solution would be to make availableDecoders a constant map again, and unconditionally add the framed snappy decoder to it, but add a feature gate check inside httpContentDecompressor when we build the map of enabled decoders. (This could also be an opportunity to add a nil check and return a proper error when requesting a non-existent or disabled decoder.)

@ArthurSens
Copy link
Member Author

Thanks for digging this up ❤️. I'll find some time to work on this later today

@ArthurSens
Copy link
Member Author

This could also be an opportunity to add a nil check and return a proper error when requesting a non-existent or disabled decoder.

It sounds like a good idea, but that would require changing the httpContentDecompressor signature to return an additional error. Right now, it only returns http.Handler. This change looks more involving than what I'd like in this PR, so I'd prefer that we work on this in a follow-up

ArthurSens and others added 2 commits May 2, 2025 11:35
@mx-psi mx-psi enabled auto-merge May 5, 2025 15:53
@mx-psi mx-psi added this pull request to the merge queue May 5, 2025
Merged via the queue into open-telemetry:main with commit c85ebbe May 5, 2025
55 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[confighttp] snappy compress, Encode and NewReader inconsistent behavior

8 participants