From 828b2889fe88bf873d027935d46a9857df489524 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 30 Dec 2021 10:51:30 -0800 Subject: [PATCH 1/4] builder: Remove deprecated include-core flag Signed-off-by: Bogdan Drutu --- CHANGELOG.md | 1 + cmd/builder/internal/builder/config.go | 13 +---- .../builder/templates/components.go.tmpl | 50 ++++--------------- cmd/builder/internal/command.go | 6 --- ...{nocore.builder.yaml => core.builder.yaml} | 15 +++--- .../test/{nocore.otel.yaml => core.otel.yaml} | 0 cmd/builder/test/replaces.builder.yaml | 18 +++++-- cmd/otelcorecol/components.go | 37 ++++---------- 8 files changed, 47 insertions(+), 93 deletions(-) rename cmd/builder/test/{nocore.builder.yaml => core.builder.yaml} (60%) rename cmd/builder/test/{nocore.otel.yaml => core.otel.yaml} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index d453a0b8bfb..6ecc96ac253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Remove deprecated consumererror.Combine (#4597) - Remove `configmapprovider.NewDefault`, `configmapprovider.NewExpand`, `configmapprovider.NewMerge` (#4600) - Move `configtest.LoadConfig` and `configtest.LoadConfigAndValidate` to `servicetest` (#4606) +- Builder: Remove deprecated `include-core` flag (#4616) ## 💡 Enhancements 💡 diff --git a/cmd/builder/internal/builder/config.go b/cmd/builder/internal/builder/config.go index e2e2f83f133..92252c49523 100644 --- a/cmd/builder/internal/builder/config.go +++ b/cmd/builder/internal/builder/config.go @@ -54,10 +54,8 @@ type Distribution struct { Go string `mapstructure:"go"` Description string `mapstructure:"description"` OtelColVersion string `mapstructure:"otelcol_version"` - // IncludeCore is deprecated and note that if this is being used, it will be removed in a subsequent release - IncludeCore bool `mapstructure:"include_core"` - OutputPath string `mapstructure:"output_path"` - Version string `mapstructure:"version"` + OutputPath string `mapstructure:"output_path"` + Version string `mapstructure:"version"` } // Module represents a receiver, exporter, processor or extension for the distribution @@ -102,13 +100,6 @@ func (c *Config) Validate() error { c.Distribution.Go = path } - // create a warning message that include_core is deprecated and will be removed in a subsequent release - if c.Distribution.IncludeCore { - c.Logger.Warn("IncludeCore is deprecated. Starting from v0.41.0, you need to include all components explicitly.") - } else { - c.Logger.Info("IncludeCore is deprecated, starting from v0.41.0. The new behavior won't affect your distribution, just remove the option from the manifest.") - } - c.Logger.Info("Using go", zap.String("go-executable", c.Distribution.Go)) return nil diff --git a/cmd/builder/internal/builder/templates/components.go.tmpl b/cmd/builder/internal/builder/templates/components.go.tmpl index f98b1dd74b8..0188bfa90d5 100644 --- a/cmd/builder/internal/builder/templates/components.go.tmpl +++ b/cmd/builder/internal/builder/templates/components.go.tmpl @@ -16,72 +16,44 @@ import ( {{- range .Receivers}} {{.Name}} "{{.Import}}" {{- end}} - {{- if .Distribution.IncludeCore}} - "go.opentelemetry.io/collector/service/defaultcomponents" - {{- end}} ) func components() (component.Factories, error) { var err error - var factories component.Factories - - {{- if .Distribution.IncludeCore}} - factories, err = defaultcomponents.Components() - if err != nil { - return component.Factories{}, err - } - {{- else}} - factories = component.Factories{} - {{- end}} + factories := component.Factories{} - extensions := []component.ExtensionFactory{ + factories.Extensions, err = component.MakeExtensionFactoryMap( {{- range .Extensions}} {{.Name}}.NewFactory(), {{- end}} - } - for _, ext := range factories.Extensions { - extensions = append(extensions, ext) - } - factories.Extensions, err = component.MakeExtensionFactoryMap(extensions...) + ) if err != nil { return component.Factories{}, err } - receivers := []component.ReceiverFactory{ + factories.Receivers, err = component.MakeReceiverFactoryMap( {{- range .Receivers}} - {{.Name}}.NewFactory(), - {{- end}} - } - for _, rcv := range factories.Receivers { - receivers = append(receivers, rcv) - } - factories.Receivers, err = component.MakeReceiverFactoryMap(receivers...) + {{.Name}}.NewFactory(), + {{- end}} + ) if err != nil { return component.Factories{}, err } - exporters := []component.ExporterFactory{ + factories.Exporters, err = component.MakeExporterFactoryMap( {{- range .Exporters}} {{.Name}}.NewFactory(), {{- end}} - } - for _, exp := range factories.Exporters { - exporters = append(exporters, exp) - } - factories.Exporters, err = component.MakeExporterFactoryMap(exporters...) + ) if err != nil { return component.Factories{}, err } - processors := []component.ProcessorFactory{ + factories.Processors, err = component.MakeProcessorFactoryMap( {{- range .Processors}} {{.Name}}.NewFactory(), {{- end}} - } - for _, pr := range factories.Processors { - processors = append(processors, pr) - } - factories.Processors, err = component.MakeProcessorFactoryMap(processors...) + ) if err != nil { return component.Factories{}, err } diff --git a/cmd/builder/internal/command.go b/cmd/builder/internal/command.go index b499f8bda1a..ced26b5e5a4 100644 --- a/cmd/builder/internal/command.go +++ b/cmd/builder/internal/command.go @@ -61,12 +61,6 @@ func Command() (*cobra.Command, error) { cmd.Flags().StringVar(&cfg.Distribution.Name, "name", "otelcol-custom", "The executable name for the OpenTelemetry Collector distribution") cmd.Flags().StringVar(&cfg.Distribution.Description, "description", "Custom OpenTelemetry Collector distribution", "A descriptive name for the OpenTelemetry Collector distribution") cmd.Flags().StringVar(&cfg.Distribution.Version, "version", "1.0.0", "The version for the OpenTelemetry Collector distribution") - // IncludeCore is deprecated and will be removed in a subsequent release - cmd.Flags().BoolVar(&cfg.Distribution.IncludeCore, "include-core", true, "Deprecated: starting from v0.41.0, core components are not going to be implicitly included.") - if err := cmd.Flags().MarkDeprecated("include-core", "IncludeCore is deprecated, please explicitly list all the components required"); err != nil { - cfg.Logger.Error("failed to mark the IncludeCore flag is deprecated", zap.Error(err)) - return nil, err - } cmd.Flags().StringVar(&cfg.Distribution.OtelColVersion, "otelcol-version", cfg.Distribution.OtelColVersion, "Which version of OpenTelemetry Collector to use as base") cmd.Flags().StringVar(&cfg.Distribution.OutputPath, "output-path", cfg.Distribution.OutputPath, "Where to write the resulting files") cmd.Flags().StringVar(&cfg.Distribution.Go, "go", "", "The Go binary to use during the compilation phase. Default: go from the PATH") diff --git a/cmd/builder/test/nocore.builder.yaml b/cmd/builder/test/core.builder.yaml similarity index 60% rename from cmd/builder/test/nocore.builder.yaml rename to cmd/builder/test/core.builder.yaml index f4a5d56ed50..dac61b6581e 100644 --- a/cmd/builder/test/nocore.builder.yaml +++ b/cmd/builder/test/core.builder.yaml @@ -1,14 +1,15 @@ dist: module: go.opentelemetry.io/collector/builder/test/nocore - otelcol_version: 0.40.0 - include_core: false + otelcol_version: 0.41.0 + +extensions: + - import: go.opentelemetry.io/collector/extension/zpagesextension + gomod: go.opentelemetry.io/collector v0.41.0 receivers: - import: go.opentelemetry.io/collector/receiver/otlpreceiver - gomod: go.opentelemetry.io/collector v0.40.0 + gomod: go.opentelemetry.io/collector v0.41.0 + exporters: - import: go.opentelemetry.io/collector/exporter/loggingexporter - gomod: go.opentelemetry.io/collector v0.40.0 -extensions: - - import: go.opentelemetry.io/collector/extension/zpagesextension - gomod: go.opentelemetry.io/collector v0.40.0 + gomod: go.opentelemetry.io/collector v0.41.0 diff --git a/cmd/builder/test/nocore.otel.yaml b/cmd/builder/test/core.otel.yaml similarity index 100% rename from cmd/builder/test/nocore.otel.yaml rename to cmd/builder/test/core.otel.yaml diff --git a/cmd/builder/test/replaces.builder.yaml b/cmd/builder/test/replaces.builder.yaml index bcdfb28c7f8..fbb96e4aa83 100644 --- a/cmd/builder/test/replaces.builder.yaml +++ b/cmd/builder/test/replaces.builder.yaml @@ -1,10 +1,22 @@ dist: module: go.opentelemetry.io/collector/builder/test/replaces - otelcol_version: 0.40.0 + otelcol_version: 0.41.0 + +extensions: + - import: go.opentelemetry.io/collector/extension/zpagesextension + gomod: go.opentelemetry.io/collector v0.41.0 + +receivers: + - import: go.opentelemetry.io/collector/receiver/otlpreceiver + gomod: go.opentelemetry.io/collector v0.41.0 processors: - - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/routingprocessor v0.40.0 - - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.40.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/routingprocessor v0.41.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.41.0 + +exporters: + - import: go.opentelemetry.io/collector/exporter/loggingexporter + gomod: go.opentelemetry.io/collector v0.41.0 replaces: - github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.40.0 diff --git a/cmd/otelcorecol/components.go b/cmd/otelcorecol/components.go index 8d09a104a08..f6e364893ab 100644 --- a/cmd/otelcorecol/components.go +++ b/cmd/otelcorecol/components.go @@ -16,53 +16,36 @@ import ( func components() (component.Factories, error) { var err error - var factories component.Factories - factories = component.Factories{} + factories := component.Factories{} - extensions := []component.ExtensionFactory{ + factories.Extensions, err = component.MakeExtensionFactoryMap( ballastextension.NewFactory(), zpagesextension.NewFactory(), - } - for _, ext := range factories.Extensions { - extensions = append(extensions, ext) - } - factories.Extensions, err = component.MakeExtensionFactoryMap(extensions...) + ) if err != nil { return component.Factories{}, err } - receivers := []component.ReceiverFactory{ - otlpreceiver.NewFactory(), - } - for _, rcv := range factories.Receivers { - receivers = append(receivers, rcv) - } - factories.Receivers, err = component.MakeReceiverFactoryMap(receivers...) + factories.Receivers, err = component.MakeReceiverFactoryMap( + otlpreceiver.NewFactory(), + ) if err != nil { return component.Factories{}, err } - exporters := []component.ExporterFactory{ + factories.Exporters, err = component.MakeExporterFactoryMap( loggingexporter.NewFactory(), otlpexporter.NewFactory(), otlphttpexporter.NewFactory(), - } - for _, exp := range factories.Exporters { - exporters = append(exporters, exp) - } - factories.Exporters, err = component.MakeExporterFactoryMap(exporters...) + ) if err != nil { return component.Factories{}, err } - processors := []component.ProcessorFactory{ + factories.Processors, err = component.MakeProcessorFactoryMap( batchprocessor.NewFactory(), memorylimiterprocessor.NewFactory(), - } - for _, pr := range factories.Processors { - processors = append(processors, pr) - } - factories.Processors, err = component.MakeProcessorFactoryMap(processors...) + ) if err != nil { return component.Factories{}, err } From 34c47998902487093df3364b17d98731f99f57ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraci=20Paix=C3=A3o=20Kr=C3=B6hling?= Date: Mon, 3 Jan 2022 18:10:39 +0100 Subject: [PATCH 2/4] Further cleanup of include core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juraci Paixão Kröhling --- cmd/builder/internal/builder/config_test.go | 6 ------ cmd/builder/test/test.sh | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/cmd/builder/internal/builder/config_test.go b/cmd/builder/internal/builder/config_test.go index e5c072494a5..00dafa2da9b 100644 --- a/cmd/builder/internal/builder/config_test.go +++ b/cmd/builder/internal/builder/config_test.go @@ -161,9 +161,3 @@ func TestDefaultConfig(t *testing.T) { require.NoError(t, cfg.ParseModules()) require.NoError(t, cfg.Validate()) } - -func TestValidateDeprecatedIncludeCoreWarnLog(t *testing.T) { - cfg := DefaultConfig() - cfg.Distribution.IncludeCore = true - require.NoError(t, cfg.Validate()) -} diff --git a/cmd/builder/test/test.sh b/cmd/builder/test/test.sh index bc4d598a8dc..5c0f269b79a 100755 --- a/cmd/builder/test/test.sh +++ b/cmd/builder/test/test.sh @@ -15,7 +15,7 @@ echo "Using ${GOBIN} to compile the distributions." # each attempt pauses for 100ms before retrying max_retries=50 -tests="replaces nocore" +tests="replaces core" base=`mktemp -d` echo "Running the tests in ${base}" From 042d72133c64564439aa50b4d3742d3aabd923e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraci=20Paix=C3=A3o=20Kr=C3=B6hling?= Date: Mon, 3 Jan 2022 18:19:47 +0100 Subject: [PATCH 3/4] make genpdata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juraci Paixão Kröhling --- cmd/otelcorecol/components.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/otelcorecol/components.go b/cmd/otelcorecol/components.go index f6e364893ab..9156edaad1a 100644 --- a/cmd/otelcorecol/components.go +++ b/cmd/otelcorecol/components.go @@ -27,8 +27,8 @@ func components() (component.Factories, error) { } factories.Receivers, err = component.MakeReceiverFactoryMap( - otlpreceiver.NewFactory(), - ) + otlpreceiver.NewFactory(), + ) if err != nil { return component.Factories{}, err } From fa85de7aedf596fa4796f60c7644b83bcfd3c01f Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Mon, 3 Jan 2022 09:34:11 -0800 Subject: [PATCH 4/4] Fix indentation in components.go.tmpl Signed-off-by: Bogdan Drutu --- cmd/builder/internal/builder/templates/components.go.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/builder/internal/builder/templates/components.go.tmpl b/cmd/builder/internal/builder/templates/components.go.tmpl index 0188bfa90d5..b213dd7bb1d 100644 --- a/cmd/builder/internal/builder/templates/components.go.tmpl +++ b/cmd/builder/internal/builder/templates/components.go.tmpl @@ -33,9 +33,9 @@ func components() (component.Factories, error) { factories.Receivers, err = component.MakeReceiverFactoryMap( {{- range .Receivers}} - {{.Name}}.NewFactory(), - {{- end}} - ) + {{.Name}}.NewFactory(), + {{- end}} + ) if err != nil { return component.Factories{}, err }