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

Update flags API #5602

Merged
merged 14 commits into from
Aug 1, 2022
Merged

Update flags API #5602

merged 14 commits into from
Aug 1, 2022

Conversation

TylerHelmuth
Copy link
Member

Description:
This PR updates the Flags API to hide all references to the Flags themselves. Instead, setting flags and checking if a flag is set is handled via functions that know about the flag being set/checked.

Link to tracking Issue:
Fixes #5443

Testing:
Updated unit tests

@TylerHelmuth
Copy link
Member Author

@bogdandrutu @dmitryax is this what you had in mind with #5443? This implementation is currently a breaking change to show final state, but I think we'd need to handle deprecating HasFlag and the original constructor.

@codecov
Copy link

codecov bot commented Jun 27, 2022

Codecov Report

Merging #5602 (1fca8d8) into main (b2dc376) will decrease coverage by 0.23%.
The diff coverage is 100.00%.

❗ Current head 1fca8d8 differs from pull request most recent head b2c4bab. Consider uploading reports for the commit b2c4bab to get more accurate results

@@            Coverage Diff             @@
##             main    #5602      +/-   ##
==========================================
- Coverage   91.77%   91.53%   -0.24%     
==========================================
  Files         192      192              
  Lines       11376    11456      +80     
==========================================
+ Hits        10440    10486      +46     
- Misses        742      776      +34     
  Partials      194      194              
Impacted Files Coverage Δ
pdata/internal/generated_pmetric.go 97.38% <100.00%> (+0.02%) ⬆️
pdata/internal/metrics.go 80.79% <100.00%> (-11.71%) ⬇️
pdata/internal/common.go 92.59% <0.00%> (-2.80%) ⬇️
service/telemetry.go 89.20% <0.00%> (ø)
component/exporter.go 100.00% <0.00%> (ø)
component/receiver.go 100.00% <0.00%> (ø)
component/processor.go 100.00% <0.00%> (ø)
config/confighttp/confighttp.go 100.00% <0.00%> (+1.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2dc376...b2c4bab. Read the comment docs.

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.

I like it.

pdata/internal/metrics.go Outdated Show resolved Hide resolved
@TylerHelmuth
Copy link
Member Author

What should the strategy be to make this backwards compatible? The NewMetricDataPointFlags func change is probably the most breaking of the changes.

@bogdandrutu
Copy link
Member

What should the strategy be to make this backwards compatible? The NewMetricDataPointFlags func change is probably the most breaking of the changes.

If too hard we can do an exception, otherwise a 2 step process is preferred, add a NewEmptyMetricDataPointFlags deprecate the current one, then remove the current add the new signature and deprecate the empty.

@TylerHelmuth
Copy link
Member Author

If too hard we can do an exception, otherwise a 2 step process is preferred, add a NewEmptyMetricDataPointFlags deprecate the current one, then remove the current add the new signature and deprecate the empty.

Done

@TylerHelmuth TylerHelmuth marked this pull request as ready for review June 29, 2022 14:53
@TylerHelmuth TylerHelmuth requested review from a team and dmitryax June 29, 2022 14:53
pdata/internal/metrics_test.go Outdated Show resolved Hide resolved
pdata/internal/metrics_test.go Outdated Show resolved Hide resolved
@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 Jul 16, 2022
@TylerHelmuth
Copy link
Member Author

Not stale, waiting for @bogdandrutu to return from PTO.

@mx-psi mx-psi removed the Stale label Jul 16, 2022
@TylerHelmuth
Copy link
Member Author

@bogdandrutu ready for another review.

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.

I think this is the final state that I envisioned, the problem is that we need to do this in multiple steps and deprecate things first.

pdata/pmetric/alias.go Outdated Show resolved Hide resolved
@@ -489,6 +493,15 @@ var exemplar = &messageValueStruct{
},
}

var dataPointFlagsFieldStruct = &messageValueField{
fieldName: "FlagsStruct",
Copy link
Member Author

Choose a reason for hiding this comment

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

Open to suggestions on this name.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds reasonable.

Copy link
Member Author

Choose a reason for hiding this comment

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

The existing Flags() api doesn't actually show as deprecated when used bc it auto-generated code. Is that ok or should we flag it and point people to FlagsStruct?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should mark that as deprecated, otherwise cannot expect people to change. We can do that in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.

pdata/internal/metrics.go Outdated Show resolved Hide resolved
@@ -489,6 +493,15 @@ var exemplar = &messageValueStruct{
},
}

var dataPointFlagsFieldStruct = &messageValueField{
fieldName: "FlagsStruct",
Copy link
Member

Choose a reason for hiding this comment

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

Sounds reasonable.

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -489,6 +493,15 @@ var exemplar = &messageValueStruct{
},
}

var dataPointFlagsFieldStruct = &messageValueField{
fieldName: "FlagsStruct",
Copy link
Member

Choose a reason for hiding this comment

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

I think we should mark that as deprecated, otherwise cannot expect people to change. We can do that in a separate PR.

@bogdandrutu bogdandrutu merged commit 3f88c04 into open-telemetry:main Aug 1, 2022
@TylerHelmuth TylerHelmuth deleted the issue-5443 branch August 1, 2022 21:24
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.

[Proposal]: Enhance [*]Flags to not need [*]Flag, and to simplify usage
3 participants