diff --git a/CHANGELOG.md b/CHANGELOG.md index a403e304d9b..f641b6a6a23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - 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 💡 @@ -35,6 +36,10 @@ 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 🛑 diff --git a/service/collector_windows.go b/service/collector_windows.go index 9e0f45b0740..a9c74c1c55d 100644 --- a/service/collector_windows.go +++ b/service/collector_windows.go @@ -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. @@ -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 { diff --git a/service/command.go b/service/command.go index cff608bb051..d71d7ca8248 100644 --- a/service/command.go +++ b/service/command.go @@ -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()) } diff --git a/service/featuregate/flags.go b/service/featuregate/flags.go index a71542de3de..2586de5e1da 100644 --- a/service/featuregate/flags.go +++ b/service/featuregate/flags.go @@ -24,9 +24,7 @@ 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, @@ -34,7 +32,7 @@ func Flags(flags *flag.FlagSet) { "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 } diff --git a/service/flags.go b/service/flags.go index 8c9f75cccab..e67e67b1652 100644 --- a/service/flags.go +++ b/service/flags.go @@ -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 { @@ -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`.") @@ -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 }