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

Add configopaque package #6470

Merged
merged 4 commits into from
Dec 1, 2022
Merged

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Nov 3, 2022

Description:

Add a configopaque.String type alias. This is the original proposal from #5653. I wanted to try this option out to make sure everyone understands the extent of breaking changes since, as mentioned on #5653 (comment), they should be minimal (as they only affect the Go API).

Link to tracking Issue: Updates #5653

@codecov
Copy link

codecov bot commented Nov 3, 2022

Codecov Report

Base: 91.20% // Head: 91.18% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (b93a46f) compared to base (64fc4de).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6470      +/-   ##
==========================================
- Coverage   91.20%   91.18%   -0.02%     
==========================================
  Files         245      246       +1     
  Lines       14194    14196       +2     
==========================================
  Hits        12945    12945              
- Misses        999     1001       +2     
  Partials      250      250              
Impacted Files Coverage Δ
config/configopaque/opaque.go 100.00% <100.00%> (ø)
obsreport/obsreporttest/obsreporttest.go 86.90% <0.00%> (-2.39%) ⬇️
config/configauth/configauth.go 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions
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 the Stale label Nov 18, 2022
@mx-psi mx-psi removed the Stale label Nov 22, 2022
@mx-psi mx-psi changed the title Add configopaque.String alias type Add configopaque package Nov 25, 2022
@mx-psi
Copy link
Member Author

mx-psi commented Nov 25, 2022

As I said on the PR description, I want to make sure we don't give up on this option just because of breaking changes: we have done many Go API breaking changes recently and I think it can be justified to do it here too if this is a better solution than struct tags. We have to think about the long term: the majority of users of this API are in the future, not the present so if we can improve things now, even at a small annoyance for current users, I think this should be the way to go.

The main two benefits I see of this option are:

  1. We have a smaller maintenance burden with this option: we only need to maintain the marshaling method on the type instead of having to provide our custom marshaling that detects struct tags for our users
  2. We can express opaqueness with higher granularity: this PR has the Headers type but we (and end-users) could have just used map[string]configopaque.String. A struct tags solution would need a special case for this kind of issue.
  3. We don't have to deal with error modes that would come in struct tags, e.g. if you add the wrong struct tag or use the incorrect type you get an error at runtime, with types the error happens at compile time.

I think this PR is representative of the changes that would be needed in contrib for updating each component (scaled by the number of components there that is :))

@mx-psi mx-psi marked this pull request as ready for review November 25, 2022 12:57
@mx-psi mx-psi requested review from a team, codeboten, jpkrohling and Aneurysm9 November 25, 2022 12:57
@mx-psi mx-psi force-pushed the mx-psi/configopaque branch from 84745d8 to 250282c Compare November 30, 2022 12:37
@mx-psi
Copy link
Member Author

mx-psi commented Nov 30, 2022

I left only the configopaque package here. The process I propose for changing a field type in several steps is:

  1. (Release v0.N) Add a new OpaqueField field with the new type and deprecate Field in favor of it. Modify code to take into account both fields (and log a warning). Make it so OpaqueField has the struct tag that Field used to have.
  2. (Release v0.N+1) Change Field to have opaque type and remove deprecation, deprecate OpaqueField in favor of Field. Move the struct tag back to Field.
  3. (Release v0.N+2) Remove (deprecated) OpaqueField field.

This would apply to both the header fields from configgrpc/confighttp structs as well as fields from contrib config structs. I think we want to make sure only one of the fields is settable when passing YAML config

If this makes sense, I will open a separate PR for doing this for headers on the confighttp/configgrpc structs and generate a list of fields on contrib after that.

@jpkrohling
Copy link
Member

Sounds like a plan!

@mx-psi
Copy link
Member Author

mx-psi commented Nov 30, 2022

If it helps on reviewing this PR, 563a9c5 from #6637 shows the first step for confighttp

config/configopaque/opaque.go Outdated Show resolved Hide resolved
@bogdandrutu bogdandrutu merged commit 7404802 into open-telemetry:main Dec 1, 2022
jaronoff97 pushed a commit to lightstep/opentelemetry-collector that referenced this pull request Dec 14, 2022
* [config/configopaque] Add configopaque.String type alias

* Apply suggestions from code review

Co-authored-by: Bogdan Drutu <lazy@splunk.com>

* [configopaque] Add Headers type

* Remove configopaque.Headers

Co-authored-by: Bogdan Drutu <lazy@splunk.com>
jaronoff97 pushed a commit to lightstep/opentelemetry-collector that referenced this pull request Dec 14, 2022
* [config/configopaque] Add configopaque.String type alias

* Apply suggestions from code review

Co-authored-by: Bogdan Drutu <lazy@splunk.com>

* [configopaque] Add Headers type

* Remove configopaque.Headers

Co-authored-by: Bogdan Drutu <lazy@splunk.com>
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.

3 participants