Skip to content

Commit

Permalink
Deprecate receivertest.NewNopFactoryForType (#11993)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bogdandrutu authored Jan 6, 2025
1 parent 40ea0a5 commit b682d8e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
25 changes: 25 additions & 0 deletions .chloggen/dep-component-type.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: 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]
3 changes: 1 addition & 2 deletions otelcol/factories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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))
Expand Down
6 changes: 0 additions & 6 deletions otelcol/testdata/components-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions receiver/receivertest/nop_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions receiver/receivertest/nop_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b682d8e

Please sign in to comment.