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

Feature gate implementation and documentation #4108

Merged
merged 17 commits into from
Oct 11, 2021

Conversation

Aneurysm9
Copy link
Member

Signed-off-by: Anthony J Mirabella a9@aneurysm9.com

Description: Splits the feature gate system from #4103. This is the feature gate library in isolation, along with documentation describing how it is to be used.

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
@Aneurysm9 Aneurysm9 requested review from a team and owais September 24, 2021 21:54
@Aneurysm9 Aneurysm9 mentioned this pull request Sep 24, 2021
config/configgates/README.md Outdated Show resolved Hide resolved
config/configgates/gates.go Outdated Show resolved Hide resolved
config/configgates/flags.go Outdated Show resolved Hide resolved
config/configgates/flags.go Outdated Show resolved Hide resolved
config/configgates/README.md Outdated Show resolved Hide resolved
config/configgates/README.md Outdated Show resolved Hide resolved
config/configgates/README.md Outdated Show resolved Hide resolved
config/configgates/README.md Outdated Show resolved Hide resolved
config/configgates/gates.go Outdated Show resolved Hide resolved
config/configgates/gates.go Outdated Show resolved Hide resolved
Moves the implementation from `config/configgates` to
`service.featuregate`.

Rearranges CLI flag handling so that it is all performed by a
ParserProvider and the ConfigUnmarshaler does not need to know about CLI
flags.

Removes `Registry` type, collapsing `frozenRegistry` to `registry` and
putting `Register()` and `Apply()` functions at the package scope.

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
@codecov
Copy link

codecov bot commented Sep 28, 2021

Codecov Report

Merging #4108 (9906381) into main (3879ce4) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4108      +/-   ##
==========================================
+ Coverage   87.65%   87.70%   +0.04%     
==========================================
  Files         173      174       +1     
  Lines       10265    10305      +40     
==========================================
+ Hits         8998     9038      +40     
  Misses       1015     1015              
  Partials      252      252              
Impacted Files Coverage Δ
service/featuregate/gates.go 100.00% <100.00%> (ø)

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 3879ce4...9906381. 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.

Some high level comments, PRs looks good in general, I really like how the feature overall shapes.

config/config.go Outdated Show resolved Hide resolved
service/featuregate/README.md Show resolved Hide resolved
service/parserprovider/gates.go Outdated Show resolved Hide resolved
service/parserprovider/gates.go Outdated Show resolved Hide resolved
config/configunmarshaler/defaultunmarshaler.go Outdated Show resolved Hide resolved
component/extension.go Outdated Show resolved Hide resolved
config/configunmarshaler/defaultunmarshaler.go Outdated Show resolved Hide resolved
config/configunmarshaler/defaultunmarshaler.go Outdated Show resolved Hide resolved
service/featuregate/README.md Outdated Show resolved Hide resolved
service/featuregate/README.md Show resolved Hide resolved
service/featuregate/README.md Outdated Show resolved Hide resolved
service/featuregate/README.md Outdated Show resolved Hide resolved
service/featuregate/README.md Outdated Show resolved Hide resolved
service/featuregate/gates.go Outdated Show resolved Hide resolved
service/featuregate/README.md Outdated Show resolved Hide resolved
Aneurysm9 and others added 7 commits September 29, 2021 13:17
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
Co-authored-by: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com>
@Aneurysm9
Copy link
Member Author

Following discussion with @bogdandrutu this has been stripped down to the minimal implementation of a global feature gate registry with exported accessor and mutator functions. We felt that this is the simplest approach and best suited to minimizing impact to the API of packages that wish to utilize feature gates. Configuration of the gates by CLI flag, environment variable, and possibly a separate feature gates config file will follow in a future PR.

@tigrannajaryan

service/featuregate/README.md Outdated Show resolved Hide resolved
service/featuregate/README.md Show resolved Hide resolved
service/featuregate/README.md Outdated Show resolved Hide resolved
service/featuregate/gates.go Show resolved Hide resolved
service/featuregate/gates_test.go Outdated Show resolved Hide resolved
Aneurysm9 and others added 2 commits October 6, 2021 10:39
Co-authored-by: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com>
Co-authored-by: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com>
@dashpole
Copy link
Contributor

dashpole commented Oct 6, 2021

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

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

LGTM.
@bogdandrutu good to merge?

@mx-psi
Copy link
Member

mx-psi commented Oct 8, 2021

I left a comment on a resolved discussion #4108 (comment) because I want to understand why the global registry approach was favored. I don't get which uses cases won't be supported by the other suggested approach in that conversation.

var reg = &registry{gates: make(map[string]Gate)}

// IsEnabled returns true if a registered feature gate is enabled and false otherwise.
func IsEnabled(id string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

@Aneurysm9 maybe as a prototype after this PR is merged, we can give a try to have the "Registry" public, with the equivalent funcs on it, and have only a "GetRegistry" func that gets the global one. This way for testing users can pass a "non-global" registry in their code, so limit the interaction with the global state.

@bogdandrutu bogdandrutu merged commit 5ee979a into open-telemetry:main Oct 11, 2021
@tigrannajaryan
Copy link
Member

Configuration of the gates by CLI flag, environment variable, and possibly a separate feature gates config file will follow in a future PR.

@Aneurysm9 just to confirm, are you working on the PR that adds the gates CLI flag?

@Aneurysm9
Copy link
Member Author

Configuration of the gates by CLI flag, environment variable, and possibly a separate feature gates config file will follow in a future PR.

@Aneurysm9 just to confirm, are you working on the PR that adds the gates CLI flag?

Yes, working on that now and I should have a PR up later today or tomorrow.

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.

5 participants