-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[confighttp] snappy compress, Encode and NewReader inconsistent behavior #10584
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
Comments
This mismatch between the reader/writer and encode/decode is called out in the library: https://pkg.go.dev/github.com/golang/snappy#pkg-overview - it explains there is a "stream" format and a "block" format. Digging a little deeper, it looks like the stream/framed format should be specified as |
Thank you for digging into this, @BinaryFissionGames! I just double-checked, and we are using readers/writers consistently in the Collector code, I believe an OTel Collector as client can compress its data using snappy and a Collector server can read it. I'm closing this issue, but if I'm missing something, let me know and I'll reopen. reader: opentelemetry-collector/config/confighttp/compression.go Lines 61 to 72 in 6fcebdb
writer: opentelemetry-collector/config/confighttp/compressor.go Lines 29 to 30 in 6fcebdb
|
I believe this issue should be reopened. Actually, we are discussing the need for consistency between streaming and framed encryption/decryption. For example, stream encryption requires stream decryption, and framed encryption requires framed decryption. However, we are unsure about the correct methods to use for encryption and decryption. origin:
|
In the post, I mentioned to use of reader/write and encode/decode. |
As I mentioned in this post, a classic example is the otlp-collector and prometheus remote write. |
so, I suggest either removing snappy decompress in the otlp-collector or replacing the current model with block format. |
Looking at the documentation for that package, we are using what should be called "x-snappy-framed". I'm not sure it's that easy for us to change from framed to block right now, as it would mean that clients and servers are not compatible anymore. I'd rather do a phased approach, where, once every couple of versions we take one of the following steps:
I believe the risk in breaking clients/servers this way is reduced, and we can then have another snappy support for block format, required by Prometheus remote write. Is it possible to implement framed format in Prometheus remote write? If so, we'd have it working on the next version already, due in a couple of weeks. |
Perhaps we could allow the receive component to choose whether to automatically decompress. |
This is a blocker for prometheus remote write, which I need to implement ASAP. |
This is still a blocker for the in-contrib prometheus-remote-write-receiver. It cannot function today. |
Hello @skandragon, Yes, this is always a question. Perhaps you could send some emails to the code owners, like @codeboten, to get their opinions. The biggest challenge in solving this issue is finding a willing sponsor to support it. If I were to implement it, I might choose to extend ServerConfig and modify the newBodyReader method. This could involve either forcibly disabling the Snappy decompression logic or providing a configuration option to specify the decompression type. opentelemetry-collector/config/confighttp/compression.go Lines 186 to 193 in a8f95d9
|
@tomatopunk I went a different route by adding format detection logic to the I do not think it is correct to keep using "snappy" content-type incorrectly, and this feels like it will unblock that concern, and ease migration to the correct wire format. |
@skandragon , you are right. We should distinguish between the two types of Snappy instead of using the confusing snappy as the Content-Encoding field. However, both Prometheus 1.0 and 2.0 protocols require Content-Encoding: snappy. Changing the protocol would take longer than adjusting the code for compatibility. If you want to quickly resolve this issue, you should consider submitting a PR to modify the Prometheus remote write protocol. https://prometheus.io/docs/specs/prw/remote_write_spec/#definitions |
@tomatopunk I think the issue is, In any case, the PR I raised seems to have gotten some attention. Let's see where that lands :) |
#### 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! <!-- Issue number if applicable --> #### Link to tracking issue Fixes #10584 --------- Signed-off-by: Arthur Silva Sens <[email protected]> Co-authored-by: Michael Graff <[email protected]> Co-authored-by: Alex Boten <[email protected]> Co-authored-by: Pablo Baeyens <[email protected]> Co-authored-by: Jonathan <[email protected]>
Hello team, I hope you are having a good day.
Describe the bug
I am coding on the collect-contrib, about on a new component to receive prometheus_remote_write.
I have encountered a potential bug related to inconsistent behavior in Snappy compression when using encode -> NewReader and NewBufferedWriter -> decode.
When we compress or decompress from a stream, or read all of it and then compress or decompress it, we get different results
Steps to reproduce
What did you expect to see?
What did you see instead?
maybe should be correctly code/decode by snappy
What version did you use?
main branch
What config did you use?
code:
opentelemetry-collector/config/confighttp/compression.go
Line 61 in 725e869
Environment
go 1.22
Additional context
In the case of Prometheus and OpenTelemetry collection, Prometheus uses encode and decode, while OpenTelemetry uses NewReader and NewBufferedWriter. However, I believe that whether you decode/encode in stream or read all and then encode/decode, the same protocol should yield the same results, and there should be no parsing failures.
code: https://github.com/prometheus/prometheus/blob/c173cd57c921f582586fc725ad51124728757533/cmd/promtool/metrics.go#L104
I would like to know how to address this bug. Should we consider skipping Snappy? If any fixes are required, I am willing to help resolve this issue.
The text was updated successfully, but these errors were encountered: