<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Make sure `flagValue.String()` can be called even when flagValue is
created by `reflect.New`
```go
import (
"flag"
"log"
"go.opentelemetry.io/collector/featuregate"
)
func main() {
fs := new(flag.FlagSet)
featuregate.GlobalRegistry().RegisterFlags(fs)
if err := fs.Parse([]string{"--help"}); err != nil {
log.Fatalf("failed to parse flags: %v", err)
}
}
```
Before this PR
```
Usage:
-feature-gates value
Comma-delimited list of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.
panic calling String method on zero featuregate.flagValue for flag feature-gates: runtime error: invalid memory address or nil pointer dereference
failed to parse flags: flag: help requested
```
Note that there is a panic in the message.
After this PR
```
Usage:
-feature-gates value
Comma-delimited list of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.
failed to parse flags: flag: help requested
```
---------
Co-authored-by: Yang Song <songy23@users.noreply.github.com>
**Description:**
Deprecate `featuregate.NewFlag` in favor of `Registry.RegisterFlags`,
which registers flags into a provided flagset.
The intent is to unblock future development of new features such as
#7991 without incurring into deprecations or breaking changes to
implement these.
This will allow us to do a 1.0 release.
**Link to tracking Issue:** Relates to #8220
* [chore] use license shortform
To remain consistent w/ contrib repo, see https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/22052
Signed-off-by: Alex Boten <aboten@lightstep.com>
* make goporto
Signed-off-by: Alex Boten <aboten@lightstep.com>
---------
Signed-off-by: Alex Boten <aboten@lightstep.com>
Finalizes the purpose of `toVersion`. `toVersion` will represent the version where the feature gate is completely removed. Setting a `stable` gate to `true` will result in a warning log. Setting a `stable` gate to `false` will result in an error.
Closes https://github.com/open-telemetry/opentelemetry-collector/issues/7621