-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(compression): Add the option of configuring compression levels #11084
base: main
Are you sure you want to change the base?
feat(compression): Add the option of configuring compression levels #11084
Conversation
0500415
to
b13f7fc
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11084 +/- ##
==========================================
- Coverage 92.14% 92.08% -0.06%
==========================================
Files 433 433
Lines 20389 20437 +48
==========================================
+ Hits 18787 18819 +32
- Misses 1238 1251 +13
- Partials 364 367 +3 ☔ View full report in Codecov by Sentry. |
2ff904d
to
e39d5e7
Compare
2165697
to
f478e7d
Compare
f478e7d
to
83cf4e5
Compare
83cf4e5
to
e58acbc
Compare
e58acbc
to
0b2b372
Compare
0b2b372
to
9fe4614
Compare
60c6f00
to
800a4c2
Compare
800a4c2
to
18d5c7b
Compare
config/confighttp/confighttp.go
Outdated
@@ -216,8 +216,13 @@ func (hcs *ClientConfig) ToClient(ctx context.Context, host component.Host, sett | |||
|
|||
// Compress the body using specified compression methods if non-empty string is provided. | |||
// Supporting gzip, zlib, deflate, snappy, and zstd; none is treated as uncompressed. | |||
var compressionTypeWithLevel configcompression.TypeWithLevel | |||
err = compressionTypeWithLevel.UnmarshalText([]byte(hcs.Compression)) |
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.
We don't need to call UnmarshalText explicitly. Changing ClientConfig.Compression
field from configcompression.Type
to configcompression.TypeWithLevel
should be enough
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.
Doing that seemed to be a breaking change. There are errors like this seen in multiple contrib components
Error: config/config.go:147:24: invalid operation: cfg.Compression != "" (mismatched types configcompression.TypeWithLevel and untyped string)
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.
Yes, it is a Go API breaking change, but not an end-user breaking change. I think this is the cleanest solution. @open-telemetry/collector-approvers let me know if you have other ideas
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.
if we make the API breaking change, are going to mute all the failing tests (in this repo) and have the contrib component owners fix that later. Sorry, I'm not clear on this process.
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.
@dmitryax would appreciate some clarity on this. The suggested API breaking change is going to break collector tests that reference components from the contrib repo. Are we ok fixing those later in a separate PR?
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.
How about keeping this as is (non-breaking) for this PR? and handle all breaking changes (core and contrib) in 2 other PRs. The only reason is, it seems to affect multiple contrib components (almost all)
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.
@dmitryax I have pushed the API breaking changes and the contrib tests(contrib-tests / contrib-tests-matrix
) seem to be failing.
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.
If you have an idea how to make it in several steps without breaking contrib and get this result, that would be great. I'm not aware of any
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 only thing I can think of is keeping Compression
as it original type in this PR i.e configcompression.Type
as suggested in a previous comment, and handling the breaking changes together.
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 think we can stick to the current plan. These are the only changes that need to go into the contrib repository
https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/35843/files
bfe8fb4
to
9ed1c64
Compare
bc6ea67
to
62be46f
Compare
62be46f
to
eaf3eea
Compare
|
||
return fmt.Errorf("unsupported compression type/level %s/%d", compressionTyp, ct.Level) |
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.
This would be confusing output if user didn't provide level
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.
this should print the default level, which I think is fine?
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 made a change to the error message, please let me know if you think this is clearer
config/confighttp/compressor.go
Outdated
if gZipCompressor.pool.Get() == nil { | ||
gZipCompressor.pool = sync.Pool{New: func() any { w, _ := gzip.NewWriterLevel(nil, int(compressionType.Level)); return w }} |
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.
This seems incorrect. We are taking compressor with any level from the pool. If user picks zlib/1
first and it goes back to the pool, the second call with any other level like zlib/2
would still give the same zlib/1
instance from the pool. We cannot reuse them compressors with different levels.
We might need a map of pools built dynamically here
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.
@dmitryax it doesn't look like the user can change the compression level dynamically? Because they would need to restart the collector to change this configuration. Wouldn't the sync.pool
be cleared when this happens?
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 created a map of compressor pools for compressors that support levels, all the tests pass with this change
c7f36ad
eaf3eea
to
c7f36ad
Compare
…el for compression
ebb77fa
to
427a8ed
Compare
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
Documentation
https://github.com/rnishtala-sumo/opentelemetry-collector/blob/configure-compression-levels/config/confighttp/README.md#client-configuration