Skip to content

Commit

Permalink
Deprecate global flag in featuregates (#5060)
Browse files Browse the repository at this point in the history
Distributions that build without the builder will need to declare it as they do for "config" and "set".

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Mar 23, 2022
1 parent e02b1c4 commit 89da10b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@
- Deprecate `pdata.AttributeValueSlice` struct in favor of `pdata.Slice`
- Deprecate `pdata.NewAttributeValueSlice` func in favor of `pdata.NewSlice`
- Deprecate LogRecord.Name(), it was deprecated in the data model (#5054)
- Deprecate global flag in `featuregates` (#5060)

### 💡 Enhancements 💡

- Change outcome of `pdata.Metric.<Gauge|Sum|Histogram|ExponentialHistogram>()` functions misuse.
In case of type mismatch, they don't panic right away but return an invalid zero-initialized
instance for consistency with other OneOf field accessors (#5034)

### 🧰 Bug fixes 🧰

- The `featuregates` were not configured from the "--feature-gates" flag on windows service (#5060)

## v0.47.0 Beta

### 🛑 Breaking changes 🛑
Expand Down
3 changes: 3 additions & 0 deletions service/collector_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"go.uber.org/zap/zapcore"
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/eventlog"

"go.opentelemetry.io/collector/service/featuregate"
)

// Deprecated: [v0.48.0] will be made private soon.
Expand Down Expand Up @@ -95,6 +97,7 @@ func (s *WindowsService) start(elog *eventlog.Log, colErrorChannel chan error) e
if err := flags().Parse(os.Args[1:]); err != nil {
return err
}
featuregate.Apply(gatesList)
var err error
s.col, err = newWithWindowsEventLogCore(s.settings, elog)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion service/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewCommand(set CollectorSettings) *cobra.Command {
Version: set.BuildInfo.Version,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
featuregate.Apply(featuregate.GetFlags())
featuregate.Apply(gatesList)
if set.ConfigProvider == nil {
set.ConfigProvider = MustNewDefaultConfigProvider(getConfigFlag(), getSetFlag())
}
Expand Down
6 changes: 2 additions & 4 deletions service/featuregate/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ const gatesListCfg = "feature-gates"

var gatesList = FlagValue{}

// Flags adds CLI flags for managing feature gates to the provided FlagSet
// Feature gates can be configured with `--feature-gates=foo,-bar`. This would
// enable the `foo` feature gate and disable the `bar` feature gate.
// Deprecated: [v0.48.0] declare distribution flag if needed.
func Flags(flags *flag.FlagSet) {
flags.Var(
gatesList,
gatesListCfg,
"Comma-delimited list of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.")
}

// GetFlags returns the FlagValue used with Flags()
// Deprecated: [v0.48.0] declare distribution flag if needed.
func GetFlags() FlagValue {
return gatesList
}
Expand Down
7 changes: 6 additions & 1 deletion service/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
// Command-line flag that control the configuration file.
configFlag = new(stringArrayValue)
setFlag = new(stringArrayValue)
gatesList = featuregate.FlagValue{}
)

type stringArrayValue struct {
Expand All @@ -42,7 +43,6 @@ func (s *stringArrayValue) String() string {

func flags() *flag.FlagSet {
flagSet := new(flag.FlagSet)
featuregate.Flags(flagSet)

flagSet.Var(configFlag, "config", "Locations to the config file(s), note that only a"+
" single location can be set per flag entry e.g. `-config=file:/path/to/first --config=file:path/to/second`.")
Expand All @@ -52,6 +52,11 @@ func flags() *flag.FlagSet {
" has a higher precedence. Array config properties are overridden and maps are joined, note that only a single"+
" (first) array property can be set e.g. -set=processors.attributes.actions.key=some_key. Example --set=processors.batch.timeout=2s")

flagSet.Var(
gatesList,
"feature-gates",
"Comma-delimited list of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.")

return flagSet
}

Expand Down

0 comments on commit 89da10b

Please sign in to comment.