Skip to content
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

feat: Add support for configuring compression levels #11805

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rnishtala-sumo
Copy link
Contributor

Description

Add the option of configuring compression levels. This is not intended to be a breaking change for the user.

Link to tracking issue

Issue - #10467

Testing

Unit tests were added/changed

@rnishtala-sumo rnishtala-sumo force-pushed the compression-config-option2 branch 3 times, most recently from 7bbcdeb to ad9e1ee Compare December 4, 2024 23:22
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 87.32394% with 9 lines in your changes missing coverage. Please review.

Project coverage is 91.53%. Comparing base (5272797) to head (ad9a8a3).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
config/confighttp/compressor.go 75.00% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11805      +/-   ##
==========================================
+ Coverage   91.44%   91.53%   +0.08%     
==========================================
  Files         446      445       -1     
  Lines       23742    23760      +18     
==========================================
+ Hits        21712    21749      +37     
+ Misses       1654     1633      -21     
- Partials      376      378       +2     

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

@rnishtala-sumo rnishtala-sumo force-pushed the compression-config-option2 branch 3 times, most recently from b9aedbf to 853d79f Compare December 5, 2024 18:41
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'breaking'
Copy link
Member

Choose a reason for hiding this comment

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

Not breaking anymore

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
Copy link
Member

Choose a reason for hiding this comment

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

Please add more details here describing a new field

import "fmt"
import (
"fmt"
)
Copy link
Member

Choose a reason for hiding this comment

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

Nit please avoid unrelated changes

@@ -36,7 +36,7 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.11 // indirect
Copy link
Member

Choose a reason for hiding this comment

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

Why is this change? It doesn't require new version right?

compressor *compressor
rt http.RoundTripper
compressionType configcompression.Type
CompressionParams configcompression.CompressionParams
Copy link
Member

Choose a reason for hiding this comment

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

to be consistent

Suggested change
CompressionParams configcompression.CompressionParams
compressionParams configcompression.CompressionParams

tests := []struct {
name string
encoding configcompression.Type
enclevel configcompression.Level
Copy link
Member

Choose a reason for hiding this comment

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

shoud be level or encLevel

}
client, err := clientSettings.ToClient(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
require.NoError(t, err)
res, err := client.Do(req)
if tt.shouldError {
assert.Error(t, err)
require.Error(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

should not be changed

@@ -104,16 +119,26 @@ func TestHTTPClientCompression(t *testing.T) {

req, err := http.NewRequest(http.MethodGet, srv.URL, reqBody)
require.NoError(t, err, "failed to create request to test handler")

compressionType := tt.encoding
err = compressionType.UnmarshalText([]byte(tt.encoding))
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need UnmarshalText?

- SpeedFastest: `1`
- SpeedDefault: `3`
- SpeedBetterCompression: `6`
- SpeedBestCompression: `11`
Copy link
Member

Choose a reason for hiding this comment

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

Does it mean that zstd has more levels? I see we don't validate that

// Checks the validity of zlib/gzip/flate compression levels
func isValidLevel(level configcompression.Level) bool {
return level == zlib.DefaultCompression ||
level == configcompression.LevelNone ||
Copy link
Member

Choose a reason for hiding this comment

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

Why not zlib.NoCompression?

level == configcompression.LevelNone ||
level == zlib.HuffmanOnly ||
level == zlib.NoCompression ||
level == zlib.BestSpeed ||
Copy link
Member

Choose a reason for hiding this comment

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

This seems redundant as we check it in the next line

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.

2 participants