Skip to content

Commit b682d8e

Browse files
authored
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 <[email protected]>
1 parent 40ea0a5 commit b682d8e

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

.chloggen/dep-component-type.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: deprecation
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: receivertest
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Deprecate receivertest.NewNopFactoryForType
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11993]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [api]

otelcol/factories_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"go.opentelemetry.io/collector/exporter/exportertest"
1212
"go.opentelemetry.io/collector/extension"
1313
"go.opentelemetry.io/collector/extension/extensiontest"
14-
"go.opentelemetry.io/collector/pipeline"
1514
"go.opentelemetry.io/collector/processor"
1615
"go.opentelemetry.io/collector/processor/processortest"
1716
"go.opentelemetry.io/collector/receiver"
@@ -38,7 +37,7 @@ func nopFactories() (Factories, error) {
3837
factories.ExtensionModules[ext.Type()] = "go.opentelemetry.io/collector/extension/extensiontest v1.2.3"
3938
}
4039

41-
if factories.Receivers, err = receiver.MakeFactoryMap(receivertest.NewNopFactory(), receivertest.NewNopFactoryForType(pipeline.SignalLogs)); err != nil {
40+
if factories.Receivers, err = receiver.MakeFactoryMap(receivertest.NewNopFactory()); err != nil {
4241
return Factories{}, err
4342
}
4443
factories.ReceiverModules = make(map[component.Type]string, len(factories.Receivers))

otelcol/testdata/components-output.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ receivers:
99
logs: Stable
1010
metrics: Stable
1111
traces: Stable
12-
- name: nop_logs
13-
module: go.opentelemetry.io/collector/receiver/receivertest v1.2.3
14-
stability:
15-
logs: Stable
16-
metrics: Undefined
17-
traces: Undefined
1812
processors:
1913
- name: nop
2014
module: go.opentelemetry.io/collector/processor/processortest v1.2.3

receiver/receivertest/nop_receiver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ func NewNopFactory() receiver.Factory {
4040
)
4141
}
4242

43-
// NewNopFactoryForType returns a receiver.Factory that constructs nop receivers supporting only the
44-
// given data type.
43+
// Deprecated: [v0.117.0] use NewNopFactory or create own factory.
4544
func NewNopFactoryForType(signal pipeline.Signal) receiver.Factory {
4645
var factoryOpt receiver.FactoryOption
4746
switch signal {

receiver/receivertest/nop_receiver_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ import (
1010
"github.com/stretchr/testify/assert"
1111
"github.com/stretchr/testify/require"
1212

13-
"go.opentelemetry.io/collector/component"
1413
"go.opentelemetry.io/collector/component/componenttest"
1514
"go.opentelemetry.io/collector/consumer/consumertest"
1615
"go.opentelemetry.io/collector/receiver/xreceiver"
1716
)
1817

19-
var nopType = component.MustNewType("nop")
20-
2118
func TestNewNopFactory(t *testing.T) {
2219
factory := NewNopFactory()
2320
require.NotNil(t, factory)
24-
assert.Equal(t, nopType, factory.Type())
21+
assert.Equal(t, "nop", factory.Type().String())
2522
cfg := factory.CreateDefaultConfig()
2623
assert.Equal(t, &nopConfig{}, cfg)
2724

0 commit comments

Comments
 (0)