diff --git a/.chloggen/remove_ErrNilNextConsumer_impl.yaml b/.chloggen/remove_ErrNilNextConsumer_impl.yaml new file mode 100644 index 000000000000..2dd87dfff4bc --- /dev/null +++ b/.chloggen/remove_ErrNilNextConsumer_impl.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: all + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove explicit checks in all receivers to check if the next consumer is nil + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [31793] + +# (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: The nil check is now done by the pipeline builder. + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# 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/processor/tailsamplingprocessor/processor.go b/processor/tailsamplingprocessor/processor.go index 9ffcb13846e0..979c790839e3 100644 --- a/processor/tailsamplingprocessor/processor.go +++ b/processor/tailsamplingprocessor/processor.go @@ -77,10 +77,6 @@ const ( // newTracesProcessor returns a processor.TracesProcessor that will perform tail sampling according to the given // configuration. func newTracesProcessor(ctx context.Context, settings component.TelemetrySettings, nextConsumer consumer.Traces, cfg Config) (processor.Traces, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } - policyNames := map[string]bool{} policies := make([]*policy, len(cfg.PolicyCfgs)) for i := range cfg.PolicyCfgs { diff --git a/receiver/awscontainerinsightreceiver/receiver.go b/receiver/awscontainerinsightreceiver/receiver.go index d192977a1341..518214fb1c62 100644 --- a/receiver/awscontainerinsightreceiver/receiver.go +++ b/receiver/awscontainerinsightreceiver/receiver.go @@ -44,9 +44,6 @@ func newAWSContainerInsightReceiver( settings component.TelemetrySettings, config *Config, nextConsumer consumer.Metrics) (receiver.Metrics, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } r := &awsContainerInsightReceiver{ settings: settings, diff --git a/receiver/awscontainerinsightreceiver/receiver_test.go b/receiver/awscontainerinsightreceiver/receiver_test.go index abe070785c74..f6b8ee900330 100644 --- a/receiver/awscontainerinsightreceiver/receiver_test.go +++ b/receiver/awscontainerinsightreceiver/receiver_test.go @@ -63,18 +63,6 @@ func TestReceiver(t *testing.T) { require.NoError(t, err) } -func TestReceiverForNilConsumer(t *testing.T) { - cfg := createDefaultConfig().(*Config) - metricsReceiver, err := newAWSContainerInsightReceiver( - componenttest.NewNopTelemetrySettings(), - cfg, - nil, - ) - - require.Error(t, err) - require.Nil(t, metricsReceiver) -} - func TestCollectData(t *testing.T) { cfg := createDefaultConfig().(*Config) metricsReceiver, err := newAWSContainerInsightReceiver( diff --git a/receiver/awsecscontainermetricsreceiver/receiver.go b/receiver/awsecscontainermetricsreceiver/receiver.go index 3004c7cda24a..d4972aac39f0 100644 --- a/receiver/awsecscontainermetricsreceiver/receiver.go +++ b/receiver/awsecscontainermetricsreceiver/receiver.go @@ -34,10 +34,6 @@ func newAWSECSContainermetrics( config *Config, nextConsumer consumer.Metrics, rest ecsutil.RestClient) (receiver.Metrics, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } - r := &awsEcsContainerMetricsReceiver{ logger: logger, nextConsumer: nextConsumer, diff --git a/receiver/awsecscontainermetricsreceiver/receiver_test.go b/receiver/awsecscontainermetricsreceiver/receiver_test.go index 88bc97f13a3b..ecfcf88cd218 100644 --- a/receiver/awsecscontainermetricsreceiver/receiver_test.go +++ b/receiver/awsecscontainermetricsreceiver/receiver_test.go @@ -53,19 +53,6 @@ func TestReceiver(t *testing.T) { require.NoError(t, err) } -func TestReceiverForNilConsumer(t *testing.T) { - cfg := createDefaultConfig().(*Config) - metricsReceiver, err := newAWSECSContainermetrics( - zap.NewNop(), - cfg, - nil, - &fakeRestClient{}, - ) - - require.Error(t, err) - require.Nil(t, metricsReceiver) -} - func TestCollectDataFromEndpoint(t *testing.T) { cfg := createDefaultConfig().(*Config) metricsReceiver, err := newAWSECSContainermetrics( diff --git a/receiver/awsfirehosereceiver/metrics_receiver.go b/receiver/awsfirehosereceiver/metrics_receiver.go index ccbe318014b6..dc3b6cca2fa1 100644 --- a/receiver/awsfirehosereceiver/metrics_receiver.go +++ b/receiver/awsfirehosereceiver/metrics_receiver.go @@ -7,7 +7,6 @@ import ( "context" "net/http" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/receiver" @@ -35,9 +34,6 @@ func newMetricsReceiver( unmarshalers map[string]unmarshaler.MetricsUnmarshaler, nextConsumer consumer.Metrics, ) (receiver.Metrics, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } configuredUnmarshaler := unmarshalers[config.RecordType] if configuredUnmarshaler == nil { diff --git a/receiver/awsxrayreceiver/receiver.go b/receiver/awsxrayreceiver/receiver.go index 887ba542adbe..08d031211110 100644 --- a/receiver/awsxrayreceiver/receiver.go +++ b/receiver/awsxrayreceiver/receiver.go @@ -42,10 +42,6 @@ func newReceiver(config *Config, consumer consumer.Traces, set receiver.CreateSettings) (receiver.Traces, error) { - if consumer == nil { - return nil, component.ErrNilNextConsumer - } - set.Logger.Info("Going to listen on endpoint for X-Ray segments", zap.String(udppoller.Transport, config.Endpoint)) poller, err := udppoller.New(&udppoller.Config{ diff --git a/receiver/carbonreceiver/receiver.go b/receiver/carbonreceiver/receiver.go index a75153d351f3..df95218d27cc 100644 --- a/receiver/carbonreceiver/receiver.go +++ b/receiver/carbonreceiver/receiver.go @@ -42,10 +42,6 @@ func newMetricsReceiver( nextConsumer consumer.Metrics, ) (receiver.Metrics, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } - if config.Endpoint == "" { return nil, errEmptyEndpoint } diff --git a/receiver/cloudfoundryreceiver/receiver.go b/receiver/cloudfoundryreceiver/receiver.go index 702fd87e1058..45d0a18ec159 100644 --- a/receiver/cloudfoundryreceiver/receiver.go +++ b/receiver/cloudfoundryreceiver/receiver.go @@ -43,10 +43,6 @@ func newCloudFoundryReceiver( config Config, nextConsumer consumer.Metrics) (receiver.Metrics, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } - obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: settings.ID, Transport: transport, diff --git a/receiver/cloudfoundryreceiver/receiver_test.go b/receiver/cloudfoundryreceiver/receiver_test.go index 794afb0ef93d..e404a71aacfb 100644 --- a/receiver/cloudfoundryreceiver/receiver_test.go +++ b/receiver/cloudfoundryreceiver/receiver_test.go @@ -37,19 +37,3 @@ func TestDefaultValidReceiver(t *testing.T) { err = receiver.Shutdown(ctx) require.NoError(t, err) } - -// Test to make sure start fails with invalid consumer -func TestInvalidConsumer(t *testing.T) { - factory := NewFactory() - cfg := factory.CreateDefaultConfig().(*Config) - params := receivertest.NewNopCreateSettings() - - receiver, err := newCloudFoundryReceiver( - params, - *cfg, - nil, - ) - - require.EqualError(t, err, "nil next Consumer") - require.Nil(t, receiver, "receiver creation failed") -} diff --git a/receiver/collectdreceiver/receiver.go b/receiver/collectdreceiver/receiver.go index 49ce8e27e1d6..0cb8a352c177 100644 --- a/receiver/collectdreceiver/receiver.go +++ b/receiver/collectdreceiver/receiver.go @@ -41,9 +41,6 @@ func newCollectdReceiver( defaultAttrsPrefix string, nextConsumer consumer.Metrics, createSettings receiver.CreateSettings) (receiver.Metrics, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } r := &collectdReceiver{ logger: logger, diff --git a/receiver/datadogreceiver/receiver.go b/receiver/datadogreceiver/receiver.go index bf4286c9b4e2..f0a40f46560f 100644 --- a/receiver/datadogreceiver/receiver.go +++ b/receiver/datadogreceiver/receiver.go @@ -26,9 +26,6 @@ type datadogReceiver struct { } func newDataDogReceiver(config *Config, nextConsumer consumer.Traces, params receiver.CreateSettings) (receiver.Traces, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } instance, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{LongLivedCtx: false, ReceiverID: params.ID, Transport: "http", ReceiverCreateSettings: params}) if err != nil { diff --git a/receiver/googlecloudpubsubreceiver/factory.go b/receiver/googlecloudpubsubreceiver/factory.go index 2c005a94e206..c2e4d024d7d6 100644 --- a/receiver/googlecloudpubsubreceiver/factory.go +++ b/receiver/googlecloudpubsubreceiver/factory.go @@ -71,9 +71,6 @@ func (factory *pubsubReceiverFactory) CreateTracesReceiver( cfg component.Config, consumer consumer.Traces) (receiver.Traces, error) { - if consumer == nil { - return nil, component.ErrNilNextConsumer - } err := cfg.(*Config).validateForTrace() if err != nil { return nil, err @@ -92,9 +89,6 @@ func (factory *pubsubReceiverFactory) CreateMetricsReceiver( cfg component.Config, consumer consumer.Metrics) (receiver.Metrics, error) { - if consumer == nil { - return nil, component.ErrNilNextConsumer - } err := cfg.(*Config).validateForMetric() if err != nil { return nil, err @@ -113,9 +107,6 @@ func (factory *pubsubReceiverFactory) CreateLogsReceiver( cfg component.Config, consumer consumer.Logs) (receiver.Logs, error) { - if consumer == nil { - return nil, component.ErrNilNextConsumer - } err := cfg.(*Config).validateForLog() if err != nil { return nil, err diff --git a/receiver/googlecloudpubsubreceiver/factory_test.go b/receiver/googlecloudpubsubreceiver/factory_test.go index 88838e0b145e..1d942b159ef6 100644 --- a/receiver/googlecloudpubsubreceiver/factory_test.go +++ b/receiver/googlecloudpubsubreceiver/factory_test.go @@ -36,8 +36,6 @@ func TestCreateTracesReceiver(t *testing.T) { tReceiver, err := factory.CreateTracesReceiver(context.Background(), params, cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, tReceiver, "traces receiver creation failed") - _, err = factory.CreateTracesReceiver(context.Background(), params, cfg, nil) - assert.Error(t, err) } func TestCreateMetricsReceiver(t *testing.T) { @@ -49,8 +47,6 @@ func TestCreateMetricsReceiver(t *testing.T) { tReceiver, err := factory.CreateMetricsReceiver(context.Background(), params, cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, tReceiver, "metrics receiver creation failed") - _, err = factory.CreateMetricsReceiver(context.Background(), params, cfg, nil) - assert.Error(t, err) } func TestCreateLogsReceiver(t *testing.T) { @@ -62,8 +58,6 @@ func TestCreateLogsReceiver(t *testing.T) { tReceiver, err := factory.CreateLogsReceiver(context.Background(), params, cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, tReceiver, "logs receiver creation failed") - _, err = factory.CreateLogsReceiver(context.Background(), params, cfg, nil) - assert.Error(t, err) } func TestEnsureReceiver(t *testing.T) { diff --git a/receiver/lokireceiver/loki.go b/receiver/lokireceiver/loki.go index 374894fc2ef3..ab79b9576ac7 100644 --- a/receiver/lokireceiver/loki.go +++ b/receiver/lokireceiver/loki.go @@ -69,10 +69,6 @@ func newLokiReceiver(conf *Config, nextConsumer consumer.Logs, settings receiver return nil, err } - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } - if conf.HTTP != nil { r.httpMux = http.NewServeMux() r.httpMux.HandleFunc("/loki/api/v1/push", func(resp http.ResponseWriter, req *http.Request) { diff --git a/receiver/opencensusreceiver/internal/ocmetrics/opencensus.go b/receiver/opencensusreceiver/internal/ocmetrics/opencensus.go index e4d3bc1110aa..a99bf7b865d3 100644 --- a/receiver/opencensusreceiver/internal/ocmetrics/opencensus.go +++ b/receiver/opencensusreceiver/internal/ocmetrics/opencensus.go @@ -12,7 +12,6 @@ import ( agentmetricspb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/metrics/v1" ocmetrics "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/receiverhelper" @@ -29,9 +28,6 @@ type Receiver struct { // New creates a new ocmetrics.Receiver reference. func New(nextConsumer consumer.Metrics, set receiver.CreateSettings) (*Receiver, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: receiverTransport, diff --git a/receiver/opencensusreceiver/internal/octrace/opencensus.go b/receiver/opencensusreceiver/internal/octrace/opencensus.go index f85e5e5a684c..8edf43e86284 100644 --- a/receiver/opencensusreceiver/internal/octrace/opencensus.go +++ b/receiver/opencensusreceiver/internal/octrace/opencensus.go @@ -11,7 +11,6 @@ import ( commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1" agenttracepb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/trace/v1" resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/receiver" @@ -34,9 +33,6 @@ type Receiver struct { // New creates a new opencensus.Receiver reference. func New(nextConsumer consumer.Traces, set receiver.CreateSettings) (*Receiver, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, diff --git a/receiver/otelarrowreceiver/factory.go b/receiver/otelarrowreceiver/factory.go index 92a32e48b99e..461919b77d4e 100644 --- a/receiver/otelarrowreceiver/factory.go +++ b/receiver/otelarrowreceiver/factory.go @@ -67,9 +67,7 @@ func createTraces( return nil, err } - if err = r.Unwrap().(*otelArrowReceiver).registerTraceConsumer(nextConsumer); err != nil { - return nil, err - } + r.Unwrap().(*otelArrowReceiver).registerTraceConsumer(nextConsumer) return r, nil } @@ -89,9 +87,7 @@ func createMetrics( return nil, err } - if err = r.Unwrap().(*otelArrowReceiver).registerMetricsConsumer(consumer); err != nil { - return nil, err - } + r.Unwrap().(*otelArrowReceiver).registerMetricsConsumer(consumer) return r, nil } @@ -111,9 +107,7 @@ func createLog( return nil, err } - if err = r.Unwrap().(*otelArrowReceiver).registerLogsConsumer(consumer); err != nil { - return nil, err - } + r.Unwrap().(*otelArrowReceiver).registerLogsConsumer(consumer) return r, nil } diff --git a/receiver/otelarrowreceiver/otelarrow.go b/receiver/otelarrowreceiver/otelarrow.go index 6130f0555288..abb7c609c7b1 100644 --- a/receiver/otelarrowreceiver/otelarrow.go +++ b/receiver/otelarrowreceiver/otelarrow.go @@ -170,28 +170,16 @@ func (r *otelArrowReceiver) Shutdown(_ context.Context) error { return err } -func (r *otelArrowReceiver) registerTraceConsumer(tc consumer.Traces) error { - if tc == nil { - return component.ErrNilNextConsumer - } +func (r *otelArrowReceiver) registerTraceConsumer(tc consumer.Traces) { r.tracesReceiver = trace.New(tc, r.obsrepGRPC) - return nil } -func (r *otelArrowReceiver) registerMetricsConsumer(mc consumer.Metrics) error { - if mc == nil { - return component.ErrNilNextConsumer - } +func (r *otelArrowReceiver) registerMetricsConsumer(mc consumer.Metrics) { r.metricsReceiver = metrics.New(mc, r.obsrepGRPC) - return nil } -func (r *otelArrowReceiver) registerLogsConsumer(lc consumer.Logs) error { - if lc == nil { - return component.ErrNilNextConsumer - } +func (r *otelArrowReceiver) registerLogsConsumer(lc consumer.Logs) { r.logsReceiver = logs.New(lc, r.obsrepGRPC) - return nil } var _ arrow.Consumers = &otelArrowReceiver{} diff --git a/receiver/receivercreator/factory.go b/receiver/receivercreator/factory.go index 26c35128a8e7..1e9aca70aac7 100644 --- a/receiver/receivercreator/factory.go +++ b/receiver/receivercreator/factory.go @@ -66,20 +66,10 @@ func createLogsReceiver( cfg component.Config, consumer consumer.Logs, ) (receiver.Logs, error) { - var err error - var recv receiver.Logs - rCfg := cfg.(*Config) r := receivers.GetOrAdd(cfg, func() component.Component { - recv, err = newLogsReceiverCreator(params, rCfg, consumer) - return recv + return newReceiverCreator(params, cfg.(*Config)) }) - rcvr := r.Component.(*receiverCreator) - if rcvr.nextLogsConsumer == nil { - rcvr.nextLogsConsumer = consumer - } - if err != nil { - return nil, err - } + r.Component.(*receiverCreator).nextLogsConsumer = consumer return r, nil } @@ -89,20 +79,10 @@ func createMetricsReceiver( cfg component.Config, consumer consumer.Metrics, ) (receiver.Metrics, error) { - var err error - var recv receiver.Logs - rCfg := cfg.(*Config) r := receivers.GetOrAdd(cfg, func() component.Component { - recv, err = newMetricsReceiverCreator(params, rCfg, consumer) - return recv + return newReceiverCreator(params, cfg.(*Config)) }) - rcvr := r.Component.(*receiverCreator) - if rcvr.nextMetricsConsumer == nil { - rcvr.nextMetricsConsumer = consumer - } - if err != nil { - return nil, err - } + r.Component.(*receiverCreator).nextMetricsConsumer = consumer return r, nil } @@ -112,19 +92,9 @@ func createTracesReceiver( cfg component.Config, consumer consumer.Traces, ) (receiver.Traces, error) { - var err error - var recv receiver.Logs - rCfg := cfg.(*Config) r := receivers.GetOrAdd(cfg, func() component.Component { - recv, err = newTracesReceiverCreator(params, rCfg, consumer) - return recv + return newReceiverCreator(params, cfg.(*Config)) }) - rcvr := r.Component.(*receiverCreator) - if rcvr.nextTracesConsumer == nil { - rcvr.nextTracesConsumer = consumer - } - if err != nil { - return nil, err - } + r.Component.(*receiverCreator).nextTracesConsumer = consumer return r, nil } diff --git a/receiver/receivercreator/receiver.go b/receiver/receivercreator/receiver.go index 704efa2608f4..7355c7c341dc 100644 --- a/receiver/receivercreator/receiver.go +++ b/receiver/receivercreator/receiver.go @@ -27,46 +27,11 @@ type receiverCreator struct { observables []observer.Observable } -// newLogsReceiverCreator creates the receiver_creator with the given parameters. -func newLogsReceiverCreator(params receiver.CreateSettings, cfg *Config, nextConsumer consumer.Logs) (receiver.Logs, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer +func newReceiverCreator(params receiver.CreateSettings, cfg *Config) receiver.Metrics { + return &receiverCreator{ + params: params, + cfg: cfg, } - - r := &receiverCreator{ - params: params, - cfg: cfg, - nextLogsConsumer: nextConsumer, - } - return r, nil -} - -// newMetricsReceiverCreator creates the receiver_creator with the given parameters. -func newMetricsReceiverCreator(params receiver.CreateSettings, cfg *Config, nextConsumer consumer.Metrics) (receiver.Metrics, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } - - r := &receiverCreator{ - params: params, - cfg: cfg, - nextMetricsConsumer: nextConsumer, - } - return r, nil -} - -// newTracesReceiverCreator creates the receiver_creator with the given parameters. -func newTracesReceiverCreator(params receiver.CreateSettings, cfg *Config, nextConsumer consumer.Traces) (receiver.Traces, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } - - r := &receiverCreator{ - params: params, - cfg: cfg, - nextTracesConsumer: nextConsumer, - } - return r, nil } // Start receiver_creator. diff --git a/receiver/signalfxreceiver/receiver.go b/receiver/signalfxreceiver/receiver.go index 077614782af3..a5053ccc71fd 100644 --- a/receiver/signalfxreceiver/receiver.go +++ b/receiver/signalfxreceiver/receiver.go @@ -122,9 +122,6 @@ func (r *sfxReceiver) RegisterLogsConsumer(lc consumer.Logs) { // By convention the consumer of the received data is set when the receiver // instance is created. func (r *sfxReceiver) Start(_ context.Context, host component.Host) error { - if r.metricsConsumer == nil && r.logsConsumer == nil { - return component.ErrNilNextConsumer - } if r.server != nil { return nil diff --git a/receiver/skywalkingreceiver/skywalking_receiver.go b/receiver/skywalkingreceiver/skywalking_receiver.go index 1da974c42fef..bf82fa58e216 100644 --- a/receiver/skywalkingreceiver/skywalking_receiver.go +++ b/receiver/skywalkingreceiver/skywalking_receiver.go @@ -70,9 +70,6 @@ func newSkywalkingReceiver( // registerTraceConsumer register a TracesReceiver that receives trace func (sr *swReceiver) registerTraceConsumer(tc consumer.Traces) error { - if tc == nil { - return component.ErrNilNextConsumer - } var err error sr.traceReceiver, err = trace.NewReceiver(tc, sr.settings) if err != nil { @@ -83,9 +80,6 @@ func (sr *swReceiver) registerTraceConsumer(tc consumer.Traces) error { // registerTraceConsumer register a TracesReceiver that receives trace func (sr *swReceiver) registerMetricsConsumer(mc consumer.Metrics) error { - if mc == nil { - return component.ErrNilNextConsumer - } var err error sr.metricsReceiver, err = metrics.NewReceiver(mc, sr.settings) if err != nil { diff --git a/receiver/solacereceiver/receiver.go b/receiver/solacereceiver/receiver.go index 70ad59598371..56e3d3fadbff 100644 --- a/receiver/solacereceiver/receiver.go +++ b/receiver/solacereceiver/receiver.go @@ -40,10 +40,6 @@ type solaceTracesReceiver struct { // newTracesReceiver creates a new solaceTraceReceiver as a receiver.Traces func newTracesReceiver(config *Config, set receiver.CreateSettings, nextConsumer consumer.Traces) (receiver.Traces, error) { - if nextConsumer == nil { - set.Logger.Warn("Next consumer in pipeline is null, stopping receiver") - return nil, component.ErrNilNextConsumer - } factory, err := newAMQPMessagingServiceFactory(config, set.Logger) if err != nil { diff --git a/receiver/statsdreceiver/factory_test.go b/receiver/statsdreceiver/factory_test.go index 095a8bd4a4d2..1ecf4f2710c4 100644 --- a/receiver/statsdreceiver/factory_test.go +++ b/receiver/statsdreceiver/factory_test.go @@ -29,15 +29,3 @@ func TestCreateReceiver(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, tReceiver, "receiver creation failed") } - -func TestCreateMetricsReceiverWithNilConsumer(t *testing.T) { - receiver, err := createMetricsReceiver( - context.Background(), - receivertest.NewNopCreateSettings(), - createDefaultConfig(), - nil, - ) - - assert.Error(t, err, "nil consumer") - assert.Nil(t, receiver) -} diff --git a/receiver/statsdreceiver/receiver.go b/receiver/statsdreceiver/receiver.go index aba562030ee1..c11ab395af4c 100644 --- a/receiver/statsdreceiver/receiver.go +++ b/receiver/statsdreceiver/receiver.go @@ -42,9 +42,6 @@ func newReceiver( config Config, nextConsumer consumer.Metrics, ) (receiver.Metrics, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } if config.NetAddr.Endpoint == "" { config.NetAddr.Endpoint = "localhost:8125" diff --git a/receiver/zipkinreceiver/trace_receiver.go b/receiver/zipkinreceiver/trace_receiver.go index 6ca40f7aed55..c525f7305e10 100644 --- a/receiver/zipkinreceiver/trace_receiver.go +++ b/receiver/zipkinreceiver/trace_receiver.go @@ -57,10 +57,6 @@ var _ http.Handler = (*zipkinReceiver)(nil) // newReceiver creates a new zipkinReceiver reference. func newReceiver(config *Config, nextConsumer consumer.Traces, settings receiver.CreateSettings) (*zipkinReceiver, error) { - if nextConsumer == nil { - return nil, component.ErrNilNextConsumer - } - transports := []string{receiverTransportV1Thrift, receiverTransportV1JSON, receiverTransportV2JSON, receiverTransportV2PROTO} obsrecvrs := make(map[string]*receiverhelper.ObsReport) for _, transport := range transports {