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

[configopaque] Mark as stable #9427

Merged
merged 4 commits into from
Feb 14, 2024

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Jan 30, 2024

Description: Fixes #9167

@mx-psi mx-psi requested review from a team and jpkrohling January 30, 2024 10:56
Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Feedback that I would like to make sure we address:

@mx-psi
Copy link
Member Author

mx-psi commented Jan 30, 2024

Should we apply the same reasoning as @mx-psi did for component.Type and make this a struct that has a for example a string Raw() to access the opaque string?

Not all strings are valid component.Types, but all strings are valid configopaque.Strings, so I don't think we get anything out of making this a struct.

@bogdandrutu
Copy link
Member

Not all strings are valid component.Types, but all strings are valid configopaque.Strings, so I don't think we get anything out of making this a struct.

Indeed, but I am worried about usability, I feel that explicitly have to call a func to get access to the underlying string clarifies the usage intent. This is not a blocker, but want to make sure we agree that is not an improvement and doesn't worth the effort.

@atoulme
Copy link
Contributor

atoulme commented Jan 30, 2024

https://github.com/open-telemetry/opentelemetry-collector/pull/9430/files is open to follow up on this.

@TylerHelmuth
Copy link
Member

Indeed, but I am worried about usability, I feel that explicitly have to call a func to get access to the underlying string clarifies the usage intent.

I agree that something like

s := configopaque.String("api-key")
r.Headers.Set("api-key", s.Raw())

is clearer than

s := configopaque.String("api-key")
r.Headers.Set("api-key", string(s))

We could update the expectation to be:

// The only way to view the value stored in a configopaque.String is to call `Raw`.

A struct may also be more future proof way to ensure the underlying value isn't exposed like it used to be before we implemented Stringer and the other Marshalers.

But also, it be a big breaking change - at this point the use is quite widespread - the benefits may not outweigh the costs.

@mx-psi
Copy link
Member Author

mx-psi commented Jan 30, 2024

Summary table of pros/cons (happy to edit and add more):

configopaque.String is a string alias configopaque.String is a struct
Pros - You can assign a string literal to configopaque.String fields

- No need for breaking changes
- More explicit way of getting the value of a configopaque.String
Cons - Less explicit way of getting the value out of a configopaque.String (type cast) - You need to explicitly use the constructor to assign to a configopaque.String field

- We need to break everybody :(

@mx-psi
Copy link
Member Author

mx-psi commented Jan 30, 2024

Should we actually test with confmap?

The way I see it we should test this on confmap:

  1. confmap should work correctly with Go types that conform to standard Go interfaces
  2. configopaque implements all the standard Go interfaces
  3. Therefore --> confmap should behave nicely with configopaque, and it's on confmap to test this

@bogdandrutu
Copy link
Member

@mx-psi then why do we test it with yaml/v3? What is special about it?

@bogdandrutu
Copy link
Member

But also, it be a big breaking change - at this point the use is quite widespread - the benefits may not outweigh the costs.

We can do it to not break contrib that bad:

  • Add constructor; Move everyone to this
  • Add getter func; Move everyone to this

Then change.

@mx-psi
Copy link
Member Author

mx-psi commented Jan 30, 2024

@mx-psi then why do we test it with yaml/v3? What is special about it?

Nothing special, just something that uses encoding.TextMarshaler. Happy to change that test something else

@TylerHelmuth
Copy link
Member

Looking at the pro/con table I'm not convinced that a change to a struct at this time is necessary. I think enough custom components outside Contrib are currently using this package that the breaking change would be significant. We've not received any user feedback that casting to a string is tricky and we've identified that expectation in the godoc. My opinion is that we move forward with the type as a string.

Copy link

codecov bot commented Jan 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (203ae9b) 90.25% compared to head (dc71a3e) 90.24%.
Report is 32 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9427      +/-   ##
==========================================
- Coverage   90.25%   90.24%   -0.02%     
==========================================
  Files         344      344              
  Lines       17932    17932              
==========================================
- Hits        16185    16182       -3     
- Misses       1419     1421       +2     
- Partials      328      329       +1     

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

@mx-psi
Copy link
Member Author

mx-psi commented Jan 31, 2024

I filed:

@andrzej-stencel
Copy link
Member

My opinion is that the explicit syntax with a struct is easier to understand what's going on when you read the code, which is the majority of what we do.

Fixing issues like this is what the unstable phase is for - iron out not only the mistakes, but also the rough edges that might make the code harder to read. I'm all for code readability and if this improves it (it does in my opinion), I believe it's worth doing.

It's not the end of the world if we don't make this change of course 🙂 But I think the "product" will be better if we do.

bogdandrutu pushed a commit that referenced this pull request Feb 1, 2024
**Description:** 

- Remove yaml test from configopaque
- Add test in confmap testing `configopaque`

**Link to tracking Issue:** From discussion on #9427
@bogdandrutu
Copy link
Member

@mx-psi should we add also an rc phase for this?

@mx-psi
Copy link
Member Author

mx-psi commented Feb 5, 2024

@bogdandrutu On #8975 we decided not to do more release candidates, and instead be more time in beta. The criteria to be able to pass from beta to stable are the ones listed on #9167 (but of course ultimately we need approval from all maintainers :)).

Is there anything specific that worries you about this package (additional to the things listed on #9427 (comment) )?

@mx-psi mx-psi added needed-for-1.0 release:required-for-ga Must be resolved before GA release and removed needed-for-1.0 labels Feb 7, 2024
@mx-psi
Copy link
Member Author

mx-psi commented Feb 8, 2024

@open-telemetry/collector-approvers as discussed offline, I believe we can merge this, PTAL

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.

🎉 🚀

@mx-psi mx-psi requested a review from bogdandrutu February 9, 2024 10:54
@mx-psi
Copy link
Member Author

mx-psi commented Feb 9, 2024

Will wait until next Wednesday to merge this to get more feedback

@mx-psi mx-psi merged commit 1c7cebb into open-telemetry:main Feb 14, 2024
63 of 78 checks passed
@github-actions github-actions bot added this to the next release milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:required-for-ga Must be resolved before GA release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stabilize configopaque
10 participants