You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a result any featuregate.IsEnabled(myFeatureGateID) checks during component factory creation (L16 in the same file) will return the default value regardless of the CLI flag. This also effects the contrib repo, for example in the googlecloud exporter this check always returns false.
Steps to reproduce
Perform a featuregate.IsEnabled() check in a NewFactory() method, for example here
What did you expect to see?
featuregate checks should work early during factory creation. They may be used to enable/disable features early on during initialization. They shouldn't have different result depending on the time they are called.
What did you see instead?
the --feature-gates CLI flag has no effect if checked during factory creation.
The factories for the components are created before the CLI flags are
evaluated. Therefore, featuregate flags are ignored during the early
startup phase.
~This PR simply shifts the time of creation of the factory map after the
CLI flag evaluation.~
Closes#4967
**Testing:**
Short manual testing via cli. Adding the following line in
`cobra.Command.RunE`.
```golang
featuregate.GlobalRegistry().VisitAll(func(fg *featuregate.Gate) { fmt.Println(fg.ID(), fg.IsEnabled()) })
```
Changing `+` & `-`:
```bash
./bin/otelcorecol_linux_amd64 --config=config.yaml --feature-gates=+telemetry.disableHighCardinalityMetrics
```
---------
Signed-off-by: Benedikt Bongartz <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
Co-authored-by: Alex Boten <[email protected]>
Describe the bug
The
--feature-gates
CLI flag is not applied until this line:opentelemetry-collector/cmd/otelcorecol/main.go
Line 34 in f980c9e
As a result any
featuregate.IsEnabled(myFeatureGateID)
checks during component factory creation (L16 in the same file) will return the default value regardless of the CLI flag. This also effects the contrib repo, for example in the googlecloud exporter this check always returns false.Steps to reproduce
Perform a
featuregate.IsEnabled()
check in aNewFactory()
method, for example hereopentelemetry-collector/exporter/otlpexporter/factory.go
Line 35 in 83c6ed1
What did you expect to see?
featuregate checks should work early during factory creation. They may be used to enable/disable features early on during initialization. They shouldn't have different result depending on the time they are called.
What did you see instead?
the
--feature-gates
CLI flag has no effect if checked during factory creation.What version did you use?
main
What config did you use?
N/A
Environment
Linux/go1.18
cc @dashpole
The text was updated successfully, but these errors were encountered: