Skip to content

Commit

Permalink
builder: start the collector with the parsing of featuregates
Browse files Browse the repository at this point in the history
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
  • Loading branch information
frzifus committed Sep 20, 2023
1 parent 07938f2 commit 92a70f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/builder/internal/builder/templates/main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ package main

import (
"log"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/otelcol"
)

func main() {
if err := otelcol.NewCommandFeatureGate().Execute(); err != nil {
log.Fatalf("failed to validate featuregates: %v", err)
}

factories, err := components()
if err != nil {
log.Fatalf("failed to build components: %v", err)
Expand Down
8 changes: 8 additions & 0 deletions otelcol/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import (
"go.opentelemetry.io/collector/featuregate"
)

// NewCommandFeatureGate constructs a new cobra.Command used to parse given FeatureGates.
func NewCommandFeatureGate() *cobra.Command {
flagSet := flags(featuregate.GlobalRegistry())
rootCmd := &cobra.Command{SilenceUsage: true}
rootCmd.Flags().AddGoFlagSet(flagSet)
return rootCmd
}

// NewCommand constructs a new cobra.Command using the given CollectorSettings.
func NewCommand(set CollectorSettings) *cobra.Command {
flagSet := flags(featuregate.GlobalRegistry())
Expand Down

0 comments on commit 92a70f4

Please sign in to comment.