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 enumeration expectations #9447

Merged

Conversation

TylerHelmuth
Copy link
Member

Description:
Adds expectations for how the repository handle enumerations

Link to tracking Issue:
Relates to #9388

@TylerHelmuth TylerHelmuth added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jan 31, 2024
@TylerHelmuth TylerHelmuth requested a review from a team as a code owner January 31, 2024 19:49
CONTRIBUTING.md Outdated
- Enumerations should use either `int` or `string` as the underlying type
- Enumeration name should be:
- Prefixed with a clarifying name *unless* the package name describes the entity of the enumeration.
- Suffixed with `Type`
Copy link
Member Author

Choose a reason for hiding this comment

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

Starting with a strict statement here so we can poke holes at this.

Immediately an enumeration like component.Kind, which has constants like ReceiverKind, would not match this role.

Copy link
Member

@dmitryax dmitryax Jan 31, 2024

Choose a reason for hiding this comment

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

Why is Type as a literal required? An enum const should be prefixed with its type. E.g. configtelemetry.LevelNone when we have type Level int32

Copy link
Member Author

Choose a reason for hiding this comment

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

An enum const should be prefixed with its type.

Agreed, I'll update that rule.

I think the largest question of the PR is "When should an Enum use Type in its name or be named Type". I've started the PR by claiming "All Enums should include Type in the name".

I don't think that is correct, but I am struggling to put into words the situations when Type is appropriate.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that is correct, but I am struggling to put into words the situations when Type is appropriate.

I don't think we should dictate using Type as literal. Sometimes it may be a good fit, sometimes not

Copy link
Member Author

Choose a reason for hiding this comment

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

@dmitryax Updated to try and put into words what Type represents, which I am currently interpreting as a sense of limited categorization.

Copy link

codecov bot commented Jan 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (89388ad) 90.24% compared to head (6f6d12c) 90.25%.
Report is 6 commits behind head on main.

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

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

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated
- Enumerations should use either `int` or `string` as the underlying type
- Enumeration name should be:
- Prefixed with a clarifying name *unless* the package name describes the entity of the enumeration.
- Suffixed with `Type`
Copy link
Member

@dmitryax dmitryax Jan 31, 2024

Choose a reason for hiding this comment

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

Why is Type as a literal required? An enum const should be prefixed with its type. E.g. configtelemetry.LevelNone when we have type Level int32

Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

To be clear: in the case of configcompression this would mean basically doing the changes in #9417, right? @dmitryax do you agree?

edit: No, for what it would entail see #9447 (comment)

@bogdandrutu
Copy link
Member

To be clear: in the case of configcompression this would mean basically doing the changes in #9417, right? @dmitryax do you agree?

I disagree, because I think having "compression" as suffix in the package name + https://github.com/open-telemetry/opentelemetry-collector/pull/9447/files#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055R261 should lead us to rename the enum as Type then make values like TypeGzip.

@mx-psi
Copy link
Member

mx-psi commented Feb 1, 2024

Ah, you are right @bogdandrutu 👍

@bogdandrutu bogdandrutu merged commit fc81583 into open-telemetry:main Feb 1, 2024
42 checks passed
@github-actions github-actions bot added this to the next release milestone Feb 1, 2024
@TylerHelmuth TylerHelmuth deleted the enumeration-expectations branch February 1, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants