From b682d8ef47cd48bdcf19dd17425cca4acfbdf477 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Mon, 6 Jan 2025 13:00:45 -0800 Subject: [PATCH] Deprecate receivertest.NewNopFactoryForType (#11993) We do not offer same for any other component test package, and also this is only used in one place across core and contrib. For consistency and limiting the public API, deprecate this functionality. Signed-off-by: Bogdan Drutu --- .chloggen/dep-component-type.yaml | 25 ++++++++++++++++++++++ otelcol/factories_test.go | 3 +-- otelcol/testdata/components-output.yaml | 6 ------ receiver/receivertest/nop_receiver.go | 3 +-- receiver/receivertest/nop_receiver_test.go | 5 +---- 5 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 .chloggen/dep-component-type.yaml diff --git a/.chloggen/dep-component-type.yaml b/.chloggen/dep-component-type.yaml new file mode 100644 index 00000000000..71d31fe1f6b --- /dev/null +++ b/.chloggen/dep-component-type.yaml @@ -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: deprecation + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: receivertest + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Deprecate receivertest.NewNopFactoryForType + +# One or more tracking issues or pull requests related to the change +issues: [11993] + +# (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: [api] diff --git a/otelcol/factories_test.go b/otelcol/factories_test.go index 15429239029..ccf28ff242c 100644 --- a/otelcol/factories_test.go +++ b/otelcol/factories_test.go @@ -11,7 +11,6 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/extension" "go.opentelemetry.io/collector/extension/extensiontest" - "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/receiver" @@ -38,7 +37,7 @@ func nopFactories() (Factories, error) { factories.ExtensionModules[ext.Type()] = "go.opentelemetry.io/collector/extension/extensiontest v1.2.3" } - if factories.Receivers, err = receiver.MakeFactoryMap(receivertest.NewNopFactory(), receivertest.NewNopFactoryForType(pipeline.SignalLogs)); err != nil { + if factories.Receivers, err = receiver.MakeFactoryMap(receivertest.NewNopFactory()); err != nil { return Factories{}, err } factories.ReceiverModules = make(map[component.Type]string, len(factories.Receivers)) diff --git a/otelcol/testdata/components-output.yaml b/otelcol/testdata/components-output.yaml index cbf14a619e1..90f262fa672 100644 --- a/otelcol/testdata/components-output.yaml +++ b/otelcol/testdata/components-output.yaml @@ -9,12 +9,6 @@ receivers: logs: Stable metrics: Stable traces: Stable - - name: nop_logs - module: go.opentelemetry.io/collector/receiver/receivertest v1.2.3 - stability: - logs: Stable - metrics: Undefined - traces: Undefined processors: - name: nop module: go.opentelemetry.io/collector/processor/processortest v1.2.3 diff --git a/receiver/receivertest/nop_receiver.go b/receiver/receivertest/nop_receiver.go index fab24a54bc7..0f9905da948 100644 --- a/receiver/receivertest/nop_receiver.go +++ b/receiver/receivertest/nop_receiver.go @@ -40,8 +40,7 @@ func NewNopFactory() receiver.Factory { ) } -// NewNopFactoryForType returns a receiver.Factory that constructs nop receivers supporting only the -// given data type. +// Deprecated: [v0.117.0] use NewNopFactory or create own factory. func NewNopFactoryForType(signal pipeline.Signal) receiver.Factory { var factoryOpt receiver.FactoryOption switch signal { diff --git a/receiver/receivertest/nop_receiver_test.go b/receiver/receivertest/nop_receiver_test.go index a921ce72601..cf7e1b15ce4 100644 --- a/receiver/receivertest/nop_receiver_test.go +++ b/receiver/receivertest/nop_receiver_test.go @@ -10,18 +10,15 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/xreceiver" ) -var nopType = component.MustNewType("nop") - func TestNewNopFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, nopType, factory.Type()) + assert.Equal(t, "nop", factory.Type().String()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg)