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(compression): Add the option of configuring compression levels #11084

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

Conversation

rnishtala-sumo
Copy link
Contributor

@rnishtala-sumo rnishtala-sumo commented Sep 9, 2024

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

@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from 0500415 to b13f7fc Compare September 9, 2024 17:05
Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 54.83871% with 28 lines in your changes missing coverage. Please review.

Project coverage is 91.33%. Comparing base (bc7af62) to head (78d83fd).
Report is 113 commits behind head on main.

Files with missing lines Patch % Lines
config/configcompression/compressiontype.go 9.52% 19 Missing ⚠️
config/confighttp/compressor.go 75.67% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11084      +/-   ##
==========================================
- Coverage   91.43%   91.33%   -0.10%     
==========================================
  Files         447      447              
  Lines       23745    23783      +38     
==========================================
+ Hits        21712    21723      +11     
- Misses       1657     1682      +25     
- 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 configure-compression-levels branch 3 times, most recently from 2ff904d to e39d5e7 Compare September 10, 2024 15:25
@rnishtala-sumo rnishtala-sumo marked this pull request as ready for review September 10, 2024 15:26
@rnishtala-sumo rnishtala-sumo requested review from a team and codeboten September 10, 2024 15:26
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch 2 times, most recently from 2165697 to f478e7d Compare September 10, 2024 19:02
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from f478e7d to 83cf4e5 Compare September 20, 2024 22:02
@rnishtala-sumo rnishtala-sumo requested a review from a team as a code owner September 20, 2024 22:02
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from 83cf4e5 to e58acbc Compare September 20, 2024 23:29
@rnishtala-sumo
Copy link
Contributor Author

@dmitrii Anoshin @alex Boten @mx-psi would appreciate some attention to this PR. It doesn't have any breaking changes.

config/confighttp/compressor.go Outdated Show resolved Hide resolved
config/confighttp/README.md Show resolved Hide resolved
"strings"

"github.com/klauspost/compress/zlib"
)

// Type represents a compression method
type Type string
Copy link
Member

@dmitryax dmitryax Sep 25, 2024

Choose a reason for hiding this comment

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

I don't think we can reuse this type and keep the level encoded in the string. API users may rely on configcompression.Type == configcompression.TypeGzip which won't work anymore...

I think we need new additional types like these

type Config struct {
	Type Type
	Level Level
}

type Level int

Config may be also called TypeWithLevel.

Given that this module is 1.x, it should be okay to add. However, we would need to make a breaking change to the Co API (not an end-user breaking change) in config HTTP by changing the confighttp.ClientConfig.Compression field from compressionconfig.Type to compressionconfig.Config, which should be okay given that the confighttp module is still 0.x.

Then we can have all validation in Config.UnmarshalText and assume that Config is always valid

cc @open-telemetry/collector-approvers

Copy link
Contributor Author

@rnishtala-sumo rnishtala-sumo Sep 30, 2024

Choose a reason for hiding this comment

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

confighttp.ClientConfig.Compression field from compressionconfig.Type to compressionconfig.Config

won't this be a breaking change for the user as well?, i.e with the above suggested change we would need two fields to specify compression like below

compression:
  type: "gzip"
  level: 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dmitryax I've made changes based on the above comment. Please let me know if this is what you had in mind.

Copy link
Contributor Author

@rnishtala-sumo rnishtala-sumo Sep 30, 2024

Choose a reason for hiding this comment

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

looks like the tests are failing because of errors like below, since this is now a breaking change

Error: config/config.go:147:24: invalid operation: cfg.Compression != "" (mismatched types configcompression.TypeWithLevel and untyped string)

There are tests in multiple contrib components that are failing because they assume the Compression is a string.

Copy link
Member

Choose a reason for hiding this comment

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

won't this be a breaking change for the user as well?,

No, we should keep the string encoding <type>/<level> where the /<level> part is optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

JFYI, I tested that with the above change both of the following configuration are valid

compression struct

exporters:
  otlphttp:
    endpoint: otelcol:4317
    compression:
      type: gzip
      level: 1

compression string

exporters:
  otlphttp:
    endpoint: otelcol:4317
    compression: gzip

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @rnishtala-sumo. To be explicit, I (obviously) think this approach looks good :)

I suppose we'll need to wait for a couple more opinions from approvers to make a final decision

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dmitryax @andrzej-stencel do you think we could proceed with @axw's approach?

Copy link
Member

@dmitryax dmitryax Dec 4, 2024

Choose a reason for hiding this comment

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

Update: We discussed this during the Collector SIG call on Dec 4. Most of the Collector leads present there (@mx-psi and @jpkrohling) favored introducing another field (compression_params) to avoid breaking the existing user interface even in a backward compatible way. @rnishtala-sumo is going to submit another PR to implement that approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's the new PR with option2 - #11805

@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from e58acbc to 0b2b372 Compare September 30, 2024 21:07
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from 0b2b372 to 9fe4614 Compare September 30, 2024 22:11
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from 60c6f00 to 800a4c2 Compare October 1, 2024 15:21
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from 800a4c2 to 18d5c7b Compare October 1, 2024 15:32
config/configcompression/compressiontype.go Outdated Show resolved Hide resolved
config/configcompression/compressiontype.go Outdated Show resolved Hide resolved
config/confighttp/compressor.go Outdated Show resolved Hide resolved
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from bfe8fb4 to 9ed1c64 Compare October 3, 2024 15:41
config/confighttp/README.md Outdated Show resolved Hide resolved
config/confighttp/README.md Outdated Show resolved Hide resolved
config/configcompression/compressiontype.go Outdated Show resolved Hide resolved
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from bc6ea67 to 62be46f Compare October 9, 2024 03:17
Copy link
Member

@andrzej-stencel andrzej-stencel left a comment

Choose a reason for hiding this comment

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

I like this approach. It's additive and doesn't break stable components.

@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from 0c53ee2 to 6bcb03a Compare November 15, 2024 23:28
Copy link
Member

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

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

Nits

config/confighttp/compression_test.go Outdated Show resolved Hide resolved
config/confighttp/compression_test.go Outdated Show resolved Hide resolved
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch 2 times, most recently from fbf2ee8 to 518d136 Compare November 18, 2024 20:20
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch 2 times, most recently from ac54499 to 976f44c Compare November 21, 2024 20:38
@rnishtala-sumo rnishtala-sumo force-pushed the configure-compression-levels branch from 976f44c to 78d83fd Compare December 4, 2024 15:52
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added Stale and removed Stale labels Dec 19, 2024
Copy link
Contributor

github-actions bot commented Jan 5, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jan 5, 2025
@mx-psi mx-psi removed the Stale label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Waiting for reviews
Development

Successfully merging this pull request may close these issues.

5 participants