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 cb52d62
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .chloggen/fix_featuregate_late_initialization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: builder

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix featuregate late initialization

# One or more tracking issues or pull requests related to the change
issues: [4967]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
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 cb52d62

Please sign in to comment.