From 1daeaf584bccc4fd027a769ff0ccacfa934104d6 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 1 Apr 2021 14:10:51 -0700 Subject: [PATCH 1/2] Add convenience interface in consumertest that implements all consumers Signed-off-by: Bogdan Drutu --- component/componenttest/nop_exporter.go | 9 ++----- component/componenttest/nop_processor.go | 8 ++---- component/componenttest/nop_processor_test.go | 6 ++--- component/componenttest/nop_receiver_test.go | 6 ++--- consumer/consumertest/consumer.go | 26 +++++++++++++++++++ consumer/consumertest/err.go | 10 +++++++ consumer/consumertest/err_test.go | 10 +++++++ consumer/consumertest/nop.go | 10 +++++++ consumer/consumertest/nop_test.go | 9 +++++++ .../fanoutconsumer/cloningconsumer_test.go | 6 ++--- consumer/fanoutconsumer/consumer_test.go | 12 ++++----- exporter/otlphttpexporter/otlp_test.go | 6 ++--- .../attributes_log_test.go | 12 ++++----- .../attributes_trace_test.go | 12 ++++----- processor/attributesprocessor/factory_test.go | 16 ++++++------ processor/filterprocessor/factory_test.go | 4 +-- .../filterprocessor/filter_processor_test.go | 4 +-- processor/memorylimiter/factory_test.go | 12 ++++----- processor/memorylimiter/memorylimiter_test.go | 6 ++--- .../factory_test.go | 2 +- .../probabilisticsampler_test.go | 8 +++--- processor/processorhelper/processor_test.go | 20 +++++++------- processor/resourceprocessor/factory_test.go | 8 +++--- processor/spanprocessor/factory_test.go | 4 +-- processor/spanprocessor/span_test.go | 20 +++++++------- receiver/hostmetricsreceiver/factory_test.go | 8 +++--- .../jaegerreceiver/trace_receiver_test.go | 4 +-- receiver/kafkareceiver/kafka_receiver_test.go | 18 ++++++------- receiver/opencensusreceiver/factory_test.go | 4 +-- .../octrace/observability_test.go | 6 ++--- .../opencensusreceiver/opencensus_test.go | 8 +++--- receiver/otlpreceiver/logs/otlp_test.go | 2 +- receiver/otlpreceiver/metrics/otlp_test.go | 2 +- receiver/otlpreceiver/otlp_test.go | 2 +- receiver/otlpreceiver/trace/otlp_test.go | 2 +- .../internal/transaction_test.go | 8 +++--- receiver/zipkinreceiver/factory_test.go | 4 +-- .../zipkinreceiver/trace_receiver_test.go | 6 ++--- .../default_processors_test.go | 6 ++--- .../default_receivers_test.go | 6 ++--- 40 files changed, 194 insertions(+), 138 deletions(-) create mode 100644 consumer/consumertest/consumer.go diff --git a/component/componenttest/nop_exporter.go b/component/componenttest/nop_exporter.go index 68511e1d3de..7c9b964d0c1 100644 --- a/component/componenttest/nop_exporter.go +++ b/component/componenttest/nop_exporter.go @@ -20,7 +20,6 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenthelper" "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" ) @@ -75,15 +74,11 @@ func (f *nopExporterFactory) CreateLogsExporter( var nopExporterInstance = &nopExporter{ Component: componenthelper.New(), - Traces: consumertest.NewTracesNop(), - Metrics: consumertest.NewMetricsNop(), - Logs: consumertest.NewLogsNop(), + Consumer: consumertest.NewNop(), } // nopExporter stores consumed traces and metrics for testing purposes. type nopExporter struct { component.Component - consumer.Traces - consumer.Metrics - consumer.Logs + consumertest.Consumer } diff --git a/component/componenttest/nop_processor.go b/component/componenttest/nop_processor.go index c773d12b7e3..213a50d3d80 100644 --- a/component/componenttest/nop_processor.go +++ b/component/componenttest/nop_processor.go @@ -78,17 +78,13 @@ func (f *nopProcessorFactory) CreateLogsProcessor( var nopProcessorInstance = &nopProcessor{ Component: componenthelper.New(), - Traces: consumertest.NewTracesNop(), - Metrics: consumertest.NewMetricsNop(), - Logs: consumertest.NewLogsNop(), + Consumer: consumertest.NewNop(), } // nopProcessor stores consumed traces and metrics for testing purposes. type nopProcessor struct { component.Component - consumer.Traces - consumer.Metrics - consumer.Logs + consumertest.Consumer } func (*nopProcessor) GetCapabilities() component.ProcessorCapabilities { diff --git a/component/componenttest/nop_processor_test.go b/component/componenttest/nop_processor_test.go index 6a3f13853a3..eda2755273b 100644 --- a/component/componenttest/nop_processor_test.go +++ b/component/componenttest/nop_processor_test.go @@ -34,21 +34,21 @@ func TestNewNopProcessorFactory(t *testing.T) { cfg := factory.CreateDefaultConfig() assert.Equal(t, &config.ProcessorSettings{TypeVal: factory.Type()}, cfg) - traces, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + traces, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.NoError(t, err) assert.Equal(t, component.ProcessorCapabilities{MutatesConsumedData: false}, traces.GetCapabilities()) assert.NoError(t, traces.Start(context.Background(), NewNopHost())) assert.NoError(t, traces.ConsumeTraces(context.Background(), pdata.NewTraces())) assert.NoError(t, traces.Shutdown(context.Background())) - metrics, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewMetricsNop()) + metrics, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.NoError(t, err) assert.Equal(t, component.ProcessorCapabilities{MutatesConsumedData: false}, metrics.GetCapabilities()) assert.NoError(t, metrics.Start(context.Background(), NewNopHost())) assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pdata.NewMetrics())) assert.NoError(t, metrics.Shutdown(context.Background())) - logs, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + logs, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.NoError(t, err) assert.Equal(t, component.ProcessorCapabilities{MutatesConsumedData: false}, logs.GetCapabilities()) assert.NoError(t, logs.Start(context.Background(), NewNopHost())) diff --git a/component/componenttest/nop_receiver_test.go b/component/componenttest/nop_receiver_test.go index 0e9904c6107..138283fcac2 100644 --- a/component/componenttest/nop_receiver_test.go +++ b/component/componenttest/nop_receiver_test.go @@ -33,17 +33,17 @@ func TestNewNopReceiverFactory(t *testing.T) { cfg := factory.CreateDefaultConfig() assert.Equal(t, &config.ReceiverSettings{TypeVal: factory.Type()}, cfg) - traces, err := factory.CreateTracesReceiver(context.Background(), component.ReceiverCreateParams{}, cfg, consumertest.NewTracesNop()) + traces, err := factory.CreateTracesReceiver(context.Background(), component.ReceiverCreateParams{}, cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, traces.Start(context.Background(), NewNopHost())) assert.NoError(t, traces.Shutdown(context.Background())) - metrics, err := factory.CreateMetricsReceiver(context.Background(), component.ReceiverCreateParams{}, cfg, consumertest.NewMetricsNop()) + metrics, err := factory.CreateMetricsReceiver(context.Background(), component.ReceiverCreateParams{}, cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, metrics.Start(context.Background(), NewNopHost())) assert.NoError(t, metrics.Shutdown(context.Background())) - logs, err := factory.CreateLogsReceiver(context.Background(), component.ReceiverCreateParams{}, cfg, consumertest.NewLogsNop()) + logs, err := factory.CreateLogsReceiver(context.Background(), component.ReceiverCreateParams{}, cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, logs.Start(context.Background(), NewNopHost())) assert.NoError(t, logs.Shutdown(context.Background())) diff --git a/consumer/consumertest/consumer.go b/consumer/consumertest/consumer.go new file mode 100644 index 00000000000..c5108f14ca3 --- /dev/null +++ b/consumer/consumertest/consumer.go @@ -0,0 +1,26 @@ +package consumertest + +import ( + "context" + + "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/consumer/pdata" +) + +// Consumer is a convenience interface that implements all consumer interfaces. +// It has a private function on it to forbid external users to implement it, +// to allow us to add extra functions without breaking compatibility because +// nobody else implements this interface. +type Consumer interface { + // ConsumeTraces to implement the consumer.Traces. + ConsumeTraces(context.Context, pdata.Traces) error + // ConsumeMetrics to implement the consumer.Metrics. + ConsumeMetrics(context.Context, pdata.Metrics) error + // ConsumeLogs to implement the consumer.Logs. + ConsumeLogs(context.Context, pdata.Logs) error + unexported() +} + +var _ consumer.Logs = (Consumer)(nil) +var _ consumer.Metrics = (Consumer)(nil) +var _ consumer.Traces = (Consumer)(nil) diff --git a/consumer/consumertest/err.go b/consumer/consumertest/err.go index e154a37cc95..c7316b5543f 100644 --- a/consumer/consumertest/err.go +++ b/consumer/consumertest/err.go @@ -25,6 +25,8 @@ type errConsumer struct { err error } +func (er *errConsumer) unexported() {} + func (er *errConsumer) ConsumeTraces(context.Context, pdata.Traces) error { return er.err } @@ -37,17 +39,25 @@ func (er *errConsumer) ConsumeLogs(context.Context, pdata.Logs) error { return er.err } +// NewErr returns a Consumer that just drops all received data and returns no error. +func NewErr(err error) Consumer { + return &errConsumer{err: err} +} + // NewTracesErr returns a consumer.Traces that just drops all received data and returns the given error. +// Deprecated: Use NewErr(). func NewTracesErr(err error) consumer.Traces { return &errConsumer{err: err} } // NewMetricsErr returns a consumer.Metrics that just drops all received data and returns the given error. +// Deprecated: Use NewErr(). func NewMetricsErr(err error) consumer.Metrics { return &errConsumer{err: err} } // NewLogsErr returns a consumer.Logs that just drops all received data and returns the given error. +// Deprecated: Use NewErr(). func NewLogsErr(err error) consumer.Logs { return &errConsumer{err: err} } diff --git a/consumer/consumertest/err_test.go b/consumer/consumertest/err_test.go index 4b5b5d6073f..6e1540cc7e4 100644 --- a/consumer/consumertest/err_test.go +++ b/consumer/consumertest/err_test.go @@ -25,6 +25,16 @@ import ( "go.opentelemetry.io/collector/consumer/pdata" ) +func TestErr(t *testing.T) { + err := errors.New("my error") + ec := NewErr(err) + require.NotNil(t, ec) + assert.NotPanics(t, ec.unexported) + assert.Equal(t, err, ec.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.Equal(t, err, ec.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.Equal(t, err, ec.ConsumeTraces(context.Background(), pdata.NewTraces())) +} + func TestTracesErr(t *testing.T) { err := errors.New("my error") nt := NewTracesErr(err) diff --git a/consumer/consumertest/nop.go b/consumer/consumertest/nop.go index b6c560398aa..505d81ba74e 100644 --- a/consumer/consumertest/nop.go +++ b/consumer/consumertest/nop.go @@ -27,6 +27,8 @@ var ( type nopConsumer struct{} +func (nc *nopConsumer) unexported() {} + func (nc *nopConsumer) ConsumeTraces(context.Context, pdata.Traces) error { return nil } @@ -39,17 +41,25 @@ func (nc *nopConsumer) ConsumeLogs(context.Context, pdata.Logs) error { return nil } +// NewNop returns a Consumer that just drops all received data and returns no error. +func NewNop() Consumer { + return nopInstance +} + // NewTracesNop returns a consumer.Traces that just drops all received data and returns no error. +// Deprecated: Use NewNop(). func NewTracesNop() consumer.Traces { return nopInstance } // NewMetricsNop returns a consumer.Metrics that just drops all received data and returns no error. +// Deprecated: Use NewNop(). func NewMetricsNop() consumer.Metrics { return nopInstance } // NewLogsNop returns a consumer.Logs that just drops all received data and returns no error. +// Deprecated: Use NewNop(). func NewLogsNop() consumer.Logs { return nopInstance } diff --git a/consumer/consumertest/nop_test.go b/consumer/consumertest/nop_test.go index c2a5b528959..a3b6a48340c 100644 --- a/consumer/consumertest/nop_test.go +++ b/consumer/consumertest/nop_test.go @@ -24,6 +24,15 @@ import ( "go.opentelemetry.io/collector/consumer/pdata" ) +func TestNop(t *testing.T) { + nc := NewNop() + require.NotNil(t, nc) + assert.NotPanics(t, nc.unexported) + assert.NoError(t, nc.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.NoError(t, nc.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.NoError(t, nc.ConsumeTraces(context.Background(), pdata.NewTraces())) +} + func TestTracesNop(t *testing.T) { nt := NewTracesNop() require.NotNil(t, nt) diff --git a/consumer/fanoutconsumer/cloningconsumer_test.go b/consumer/fanoutconsumer/cloningconsumer_test.go index f9aeaf1b53d..9f46d4778f3 100644 --- a/consumer/fanoutconsumer/cloningconsumer_test.go +++ b/consumer/fanoutconsumer/cloningconsumer_test.go @@ -26,7 +26,7 @@ import ( ) func TestTraceProcessorCloningNotMultiplexing(t *testing.T) { - nop := consumertest.NewTracesNop() + nop := consumertest.NewNop() tfc := NewTracesCloning([]consumer.Traces{nop}) assert.Same(t, nop, tfc) } @@ -69,7 +69,7 @@ func TestTraceProcessorCloningMultiplexing(t *testing.T) { } func TestMetricsProcessorCloningNotMultiplexing(t *testing.T) { - nop := consumertest.NewMetricsNop() + nop := consumertest.NewNop() mfc := NewMetrics([]consumer.Metrics{nop}) assert.Same(t, nop, mfc) } @@ -112,7 +112,7 @@ func TestMetricsProcessorCloningMultiplexing(t *testing.T) { } func TestLogsProcessorCloningNotMultiplexing(t *testing.T) { - nop := consumertest.NewLogsNop() + nop := consumertest.NewNop() lfc := NewLogsCloning([]consumer.Logs{nop}) assert.Same(t, nop, lfc) } diff --git a/consumer/fanoutconsumer/consumer_test.go b/consumer/fanoutconsumer/consumer_test.go index 0f03c409a32..5317ca2f6fb 100644 --- a/consumer/fanoutconsumer/consumer_test.go +++ b/consumer/fanoutconsumer/consumer_test.go @@ -27,7 +27,7 @@ import ( ) func TestTracesProcessorNotMultiplexing(t *testing.T) { - nop := consumertest.NewTracesNop() + nop := consumertest.NewNop() tfc := NewTraces([]consumer.Traces{nop}) assert.Same(t, nop, tfc) } @@ -65,7 +65,7 @@ func TestTraceProcessorWhenOneErrors(t *testing.T) { } // Make one processor return error - processors[1] = consumertest.NewTracesErr(errors.New("my error")) + processors[1] = consumertest.NewErr(errors.New("my error")) tfc := NewTraces(processors) td := testdata.GenerateTraceDataOneSpan() @@ -81,7 +81,7 @@ func TestTraceProcessorWhenOneErrors(t *testing.T) { } func TestMetricsProcessorNotMultiplexing(t *testing.T) { - nop := consumertest.NewMetricsNop() + nop := consumertest.NewNop() mfc := NewMetrics([]consumer.Metrics{nop}) assert.Same(t, nop, mfc) } @@ -119,7 +119,7 @@ func TestMetricsProcessorWhenOneErrors(t *testing.T) { } // Make one processor return error - processors[1] = consumertest.NewMetricsErr(errors.New("my error")) + processors[1] = consumertest.NewErr(errors.New("my error")) mfc := NewMetrics(processors) md := testdata.GenerateMetricsOneMetric() @@ -135,7 +135,7 @@ func TestMetricsProcessorWhenOneErrors(t *testing.T) { } func TestLogsProcessorNotMultiplexing(t *testing.T) { - nop := consumertest.NewLogsNop() + nop := consumertest.NewNop() lfc := NewLogs([]consumer.Logs{nop}) assert.Same(t, nop, lfc) } @@ -173,7 +173,7 @@ func TestLogsProcessorWhenOneErrors(t *testing.T) { } // Make one processor return error - processors[1] = consumertest.NewLogsErr(errors.New("my error")) + processors[1] = consumertest.NewErr(errors.New("my error")) lfc := NewLogs(processors) ld := testdata.GenerateLogDataOneLog() diff --git a/exporter/otlphttpexporter/otlp_test.go b/exporter/otlphttpexporter/otlp_test.go index 7699c7552af..332563e984d 100644 --- a/exporter/otlphttpexporter/otlp_test.go +++ b/exporter/otlphttpexporter/otlp_test.go @@ -80,7 +80,7 @@ func TestTraceInvalidUrl(t *testing.T) { func TestTraceError(t *testing.T) { addr := testutil.GetAvailableLocalAddress(t) - startTraceReceiver(t, addr, consumertest.NewTracesErr(errors.New("my_error"))) + startTraceReceiver(t, addr, consumertest.NewErr(errors.New("my_error"))) exp := startTraceExporter(t, "", fmt.Sprintf("http://%s/v1/traces", addr)) td := testdata.GenerateTraceDataOneSpan() @@ -188,7 +188,7 @@ func TestCompressionOptions(t *testing.T) { func TestMetricsError(t *testing.T) { addr := testutil.GetAvailableLocalAddress(t) - startMetricsReceiver(t, addr, consumertest.NewMetricsErr(errors.New("my_error"))) + startMetricsReceiver(t, addr, consumertest.NewErr(errors.New("my_error"))) exp := startMetricsExporter(t, "", fmt.Sprintf("http://%s/v1/metrics", addr)) md := testdata.GenerateMetricsOneMetric() @@ -241,7 +241,7 @@ func TestMetricsRoundTrip(t *testing.T) { func TestLogsError(t *testing.T) { addr := testutil.GetAvailableLocalAddress(t) - startLogsReceiver(t, addr, consumertest.NewLogsErr(errors.New("my_error"))) + startLogsReceiver(t, addr, consumertest.NewErr(errors.New("my_error"))) exp := startLogsExporter(t, "", fmt.Sprintf("http://%s/v1/logs", addr)) md := testdata.GenerateLogDataOneLog() diff --git a/processor/attributesprocessor/attributes_log_test.go b/processor/attributesprocessor/attributes_log_test.go index 2bf0afe50a7..058ad5a5b87 100644 --- a/processor/attributesprocessor/attributes_log_test.go +++ b/processor/attributesprocessor/attributes_log_test.go @@ -111,7 +111,7 @@ func TestLogProcessor_NilEmptyData(t *testing.T) { } tp, err := factory.CreateLogsProcessor( - context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewLogsNop()) + context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) for i := range testCases { @@ -174,7 +174,7 @@ func TestAttributes_FilterLogs(t *testing.T) { }, Config: *createConfig(filterset.Strict), } - tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -237,7 +237,7 @@ func TestAttributes_FilterLogsByNameStrict(t *testing.T) { LogNames: []string{"dont_apply"}, Config: *createConfig(filterset.Strict), } - tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -300,7 +300,7 @@ func TestAttributes_FilterLogsByNameRegexp(t *testing.T) { LogNames: []string{".*dont_apply$"}, Config: *createConfig(filterset.Regexp), } - tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -359,7 +359,7 @@ func TestLogAttributes_Hash(t *testing.T) { {Key: "user.authenticated", Action: processorhelper.HASH}, } - tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -403,7 +403,7 @@ func BenchmarkAttributes_FilterLogsByName(b *testing.B) { oCfg.Include = &filterconfig.MatchProperties{ LogNames: []string{"^apply.*"}, } - tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + tp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(b, err) require.NotNil(b, tp) diff --git a/processor/attributesprocessor/attributes_trace_test.go b/processor/attributesprocessor/attributes_trace_test.go index a6eaf7f7506..68ffec31cf6 100644 --- a/processor/attributesprocessor/attributes_trace_test.go +++ b/processor/attributesprocessor/attributes_trace_test.go @@ -120,7 +120,7 @@ func TestSpanProcessor_NilEmptyData(t *testing.T) { {Key: "attribute1", Action: processorhelper.DELETE}, } - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) for i := range testCases { @@ -187,7 +187,7 @@ func TestAttributes_FilterSpans(t *testing.T) { }, Config: *createConfig(filterset.Strict), } - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -255,7 +255,7 @@ func TestAttributes_FilterSpansByNameStrict(t *testing.T) { SpanNames: []string{"dont_apply"}, Config: *createConfig(filterset.Strict), } - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -323,7 +323,7 @@ func TestAttributes_FilterSpansByNameRegexp(t *testing.T) { SpanNames: []string{".*dont_apply$"}, Config: *createConfig(filterset.Regexp), } - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -382,7 +382,7 @@ func TestAttributes_Hash(t *testing.T) { {Key: "user.authenticated", Action: processorhelper.HASH}, } - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -426,7 +426,7 @@ func BenchmarkAttributes_FilterSpansByName(b *testing.B) { oCfg.Include = &filterconfig.MatchProperties{ SpanNames: []string{"^apply.*"}, } - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(b, err) require.NotNil(b, tp) diff --git a/processor/attributesprocessor/factory_test.go b/processor/attributesprocessor/factory_test.go index a4f7c6293ee..9828b7ce8f8 100644 --- a/processor/attributesprocessor/factory_test.go +++ b/processor/attributesprocessor/factory_test.go @@ -46,7 +46,7 @@ func TestFactory_CreateDefaultConfig(t *testing.T) { func TestFactoryCreateTraceProcessor_EmptyActions(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - ap, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + ap, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.Error(t, err) assert.Nil(t, ap) } @@ -59,7 +59,7 @@ func TestFactoryCreateTraceProcessor_InvalidActions(t *testing.T) { oCfg.Actions = []processorhelper.ActionKeyValue{ {Key: "", Value: 123, Action: processorhelper.UPSERT}, } - ap, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + ap, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.Error(t, err) assert.Nil(t, ap) } @@ -72,7 +72,7 @@ func TestFactoryCreateTraceProcessor(t *testing.T) { {Key: "a key", Action: processorhelper.DELETE}, } - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.NotNil(t, tp) assert.NoError(t, err) @@ -83,7 +83,7 @@ func TestFactoryCreateTraceProcessor(t *testing.T) { oCfg.Actions = []processorhelper.ActionKeyValue{ {Action: processorhelper.DELETE}, } - tp, err = factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + tp, err = factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.Nil(t, tp) assert.Error(t, err) } @@ -100,7 +100,7 @@ func TestFactory_CreateMetricsProcessor(t *testing.T) { func TestFactoryCreateLogsProcessor_EmptyActions(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - ap, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + ap, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.Error(t, err) assert.Nil(t, ap) } @@ -113,7 +113,7 @@ func TestFactoryCreateLogsProcessor_InvalidActions(t *testing.T) { oCfg.Actions = []processorhelper.ActionKeyValue{ {Key: "", Value: 123, Action: processorhelper.UPSERT}, } - ap, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + ap, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.Error(t, err) assert.Nil(t, ap) } @@ -127,7 +127,7 @@ func TestFactoryCreateLogsProcessor(t *testing.T) { } tp, err := factory.CreateLogsProcessor( - context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.NotNil(t, tp) assert.NoError(t, err) @@ -140,7 +140,7 @@ func TestFactoryCreateLogsProcessor(t *testing.T) { {Action: processorhelper.DELETE}, } tp, err = factory.CreateLogsProcessor( - context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewLogsNop()) + context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.Nil(t, tp) assert.Error(t, err) } diff --git a/processor/filterprocessor/factory_test.go b/processor/filterprocessor/factory_test.go index 727573bf808..6158239dc8b 100644 --- a/processor/filterprocessor/factory_test.go +++ b/processor/filterprocessor/factory_test.go @@ -77,12 +77,12 @@ func TestCreateProcessors(t *testing.T) { t.Run(fmt.Sprintf("%s/%s", test.configName, name), func(t *testing.T) { factory := NewFactory() - tp, tErr := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewTracesNop()) + tp, tErr := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) // Not implemented error assert.NotNil(t, tErr) assert.Nil(t, tp) - mp, mErr := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewMetricsNop()) + mp, mErr := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) assert.Equal(t, test.succeed, mp != nil) assert.Equal(t, test.succeed, mErr == nil) }) diff --git a/processor/filterprocessor/filter_processor_test.go b/processor/filterprocessor/filter_processor_test.go index 15d83e605b1..b4b61dda458 100644 --- a/processor/filterprocessor/filter_processor_test.go +++ b/processor/filterprocessor/filter_processor_test.go @@ -454,7 +454,7 @@ func benchmarkFilter(b *testing.B, mp *filtermetric.MatchProperties) { ctx, component.ProcessorCreateParams{}, cfg, - consumertest.NewMetricsNop(), + consumertest.NewNop(), ) pdms := metricSlice(128) for i := 0; i < b.N; i++ { @@ -557,7 +557,7 @@ func requireNotPanics(t *testing.T, metrics pdata.Metrics) { Logger: zap.NewNop(), }, cfg, - consumertest.NewMetricsNop(), + consumertest.NewNop(), ) require.NotPanics(t, func() { _ = proc.ConsumeMetrics(ctx, metrics) diff --git a/processor/memorylimiter/factory_test.go b/processor/memorylimiter/factory_test.go index c7ee2eba04a..0134f2dded1 100644 --- a/processor/memorylimiter/factory_test.go +++ b/processor/memorylimiter/factory_test.go @@ -44,15 +44,15 @@ func TestCreateProcessor(t *testing.T) { cfg := factory.CreateDefaultConfig() // This processor can't be created with the default config. - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) assert.Nil(t, tp) assert.Error(t, err, "created processor with invalid settings") - mp, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewMetricsNop()) + mp, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) assert.Nil(t, mp) assert.Error(t, err, "created processor with invalid settings") - lp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewLogsNop()) + lp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) assert.Nil(t, lp) assert.Error(t, err, "created processor with invalid settings") @@ -63,17 +63,17 @@ func TestCreateProcessor(t *testing.T) { pCfg.BallastSizeMiB = 2048 pCfg.CheckInterval = 100 * time.Millisecond - tp, err = factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewTracesNop()) + tp, err = factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, tp) assert.NoError(t, tp.Shutdown(context.Background())) - mp, err = factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewMetricsNop()) + mp, err = factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, mp) assert.NoError(t, mp.Shutdown(context.Background())) - lp, err = factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewLogsNop()) + lp, err = factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, lp) assert.NoError(t, lp.Shutdown(context.Background())) diff --git a/processor/memorylimiter/memorylimiter_test.go b/processor/memorylimiter/memorylimiter_test.go index ed3d6843cb8..b2b4b8d5efb 100644 --- a/processor/memorylimiter/memorylimiter_test.go +++ b/processor/memorylimiter/memorylimiter_test.go @@ -121,7 +121,7 @@ func TestMetricsMemoryPressureResponse(t *testing.T) { &Config{ ProcessorSettings: config.NewProcessorSettings(typeStr), }, - consumertest.NewMetricsNop(), + consumertest.NewNop(), ml, processorhelper.WithCapabilities(processorCapabilities), processorhelper.WithShutdown(ml.shutdown)) @@ -192,7 +192,7 @@ func TestTraceMemoryPressureResponse(t *testing.T) { &Config{ ProcessorSettings: config.NewProcessorSettings(typeStr), }, - consumertest.NewTracesNop(), + consumertest.NewNop(), ml, processorhelper.WithCapabilities(processorCapabilities), processorhelper.WithShutdown(ml.shutdown)) @@ -263,7 +263,7 @@ func TestLogMemoryPressureResponse(t *testing.T) { &Config{ ProcessorSettings: config.NewProcessorSettings(typeStr), }, - consumertest.NewLogsNop(), + consumertest.NewNop(), ml, processorhelper.WithCapabilities(processorCapabilities), processorhelper.WithShutdown(ml.shutdown)) diff --git a/processor/probabilisticsamplerprocessor/factory_test.go b/processor/probabilisticsamplerprocessor/factory_test.go index 3f39318e456..fc0fb89a6c6 100644 --- a/processor/probabilisticsamplerprocessor/factory_test.go +++ b/processor/probabilisticsamplerprocessor/factory_test.go @@ -35,7 +35,7 @@ func TestCreateDefaultConfig(t *testing.T) { func TestCreateProcessor(t *testing.T) { cfg := createDefaultConfig() params := component.ProcessorCreateParams{Logger: zap.NewNop()} - tp, err := createTraceProcessor(context.Background(), params, cfg, consumertest.NewTracesNop()) + tp, err := createTraceProcessor(context.Background(), params, cfg, consumertest.NewNop()) assert.NotNil(t, tp) assert.NoError(t, err, "cannot create trace processor") } diff --git a/processor/probabilisticsamplerprocessor/probabilisticsampler_test.go b/processor/probabilisticsamplerprocessor/probabilisticsampler_test.go index 896016970b1..e63378f91b1 100644 --- a/processor/probabilisticsamplerprocessor/probabilisticsampler_test.go +++ b/processor/probabilisticsamplerprocessor/probabilisticsampler_test.go @@ -45,23 +45,23 @@ func TestNewTraceProcessor(t *testing.T) { }, { name: "happy_path", - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), cfg: Config{ SamplingPercentage: 15.5, }, want: &tracesamplerprocessor{ - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), }, }, { name: "happy_path_hash_seed", - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), cfg: Config{ SamplingPercentage: 13.33, HashSeed: 4321, }, want: &tracesamplerprocessor{ - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), hashSeed: 4321, }, }, diff --git a/processor/processorhelper/processor_test.go b/processor/processorhelper/processor_test.go index dba91f65fc5..0f2fa8d66c6 100644 --- a/processor/processorhelper/processor_test.go +++ b/processor/processorhelper/processor_test.go @@ -57,7 +57,7 @@ func TestWithOptions(t *testing.T) { } func TestNewTraceExporter(t *testing.T) { - me, err := NewTraceProcessor(testCfg, consumertest.NewTracesNop(), newTestTProcessor(nil)) + me, err := NewTraceProcessor(testCfg, consumertest.NewNop(), newTestTProcessor(nil)) require.NoError(t, err) assert.NoError(t, me.Start(context.Background(), componenttest.NewNopHost())) @@ -66,7 +66,7 @@ func TestNewTraceExporter(t *testing.T) { } func TestNewTraceExporter_NilRequiredFields(t *testing.T) { - _, err := NewTraceProcessor(testCfg, consumertest.NewTracesNop(), nil) + _, err := NewTraceProcessor(testCfg, consumertest.NewNop(), nil) assert.Error(t, err) _, err = NewTraceProcessor(testCfg, nil, newTestTProcessor(nil)) @@ -75,13 +75,13 @@ func TestNewTraceExporter_NilRequiredFields(t *testing.T) { func TestNewTraceExporter_ProcessTraceError(t *testing.T) { want := errors.New("my_error") - me, err := NewTraceProcessor(testCfg, consumertest.NewTracesNop(), newTestTProcessor(want)) + me, err := NewTraceProcessor(testCfg, consumertest.NewNop(), newTestTProcessor(want)) require.NoError(t, err) assert.Equal(t, want, me.ConsumeTraces(context.Background(), testdata.GenerateTraceDataEmpty())) } func TestNewMetricsExporter(t *testing.T) { - me, err := NewMetricsProcessor(testCfg, consumertest.NewMetricsNop(), newTestMProcessor(nil)) + me, err := NewMetricsProcessor(testCfg, consumertest.NewNop(), newTestMProcessor(nil)) require.NoError(t, err) assert.NoError(t, me.Start(context.Background(), componenttest.NewNopHost())) @@ -90,7 +90,7 @@ func TestNewMetricsExporter(t *testing.T) { } func TestNewMetricsExporter_NilRequiredFields(t *testing.T) { - _, err := NewMetricsProcessor(testCfg, consumertest.NewMetricsNop(), nil) + _, err := NewMetricsProcessor(testCfg, consumertest.NewNop(), nil) assert.Error(t, err) _, err = NewMetricsProcessor(testCfg, nil, newTestMProcessor(nil)) @@ -99,19 +99,19 @@ func TestNewMetricsExporter_NilRequiredFields(t *testing.T) { func TestNewMetricsExporter_ProcessMetricsError(t *testing.T) { want := errors.New("my_error") - me, err := NewMetricsProcessor(testCfg, consumertest.NewMetricsNop(), newTestMProcessor(want)) + me, err := NewMetricsProcessor(testCfg, consumertest.NewNop(), newTestMProcessor(want)) require.NoError(t, err) assert.Equal(t, want, me.ConsumeMetrics(context.Background(), testdata.GenerateMetricsEmpty())) } func TestNewMetricsExporter_ProcessMetricsErrSkipProcessingData(t *testing.T) { - me, err := NewMetricsProcessor(testCfg, consumertest.NewMetricsNop(), newTestMProcessor(ErrSkipProcessingData)) + me, err := NewMetricsProcessor(testCfg, consumertest.NewNop(), newTestMProcessor(ErrSkipProcessingData)) require.NoError(t, err) assert.Equal(t, nil, me.ConsumeMetrics(context.Background(), testdata.GenerateMetricsEmpty())) } func TestNewLogsExporter(t *testing.T) { - me, err := NewLogsProcessor(testCfg, consumertest.NewLogsNop(), newTestLProcessor(nil)) + me, err := NewLogsProcessor(testCfg, consumertest.NewNop(), newTestLProcessor(nil)) require.NoError(t, err) assert.NoError(t, me.Start(context.Background(), componenttest.NewNopHost())) @@ -120,7 +120,7 @@ func TestNewLogsExporter(t *testing.T) { } func TestNewLogsExporter_NilRequiredFields(t *testing.T) { - _, err := NewLogsProcessor(testCfg, consumertest.NewLogsNop(), nil) + _, err := NewLogsProcessor(testCfg, consumertest.NewNop(), nil) assert.Error(t, err) _, err = NewLogsProcessor(testCfg, nil, newTestLProcessor(nil)) @@ -129,7 +129,7 @@ func TestNewLogsExporter_NilRequiredFields(t *testing.T) { func TestNewLogsExporter_ProcessLogError(t *testing.T) { want := errors.New("my_error") - me, err := NewLogsProcessor(testCfg, consumertest.NewLogsNop(), newTestLProcessor(want)) + me, err := NewLogsProcessor(testCfg, consumertest.NewNop(), newTestLProcessor(want)) require.NoError(t, err) assert.Equal(t, want, me.ConsumeLogs(context.Background(), testdata.GenerateLogDataEmpty())) } diff --git a/processor/resourceprocessor/factory_test.go b/processor/resourceprocessor/factory_test.go index 62ade8723c2..6c241de9e20 100644 --- a/processor/resourceprocessor/factory_test.go +++ b/processor/resourceprocessor/factory_test.go @@ -43,11 +43,11 @@ func TestCreateProcessor(t *testing.T) { }, } - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, tp) - mp, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewMetricsNop()) + mp, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, mp) } @@ -56,10 +56,10 @@ func TestInvalidEmptyActions(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - _, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + _, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.Error(t, err) - _, err = factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewMetricsNop()) + _, err = factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) assert.Error(t, err) } diff --git a/processor/spanprocessor/factory_test.go b/processor/spanprocessor/factory_test.go index 7a41a7d046e..f940eb87f35 100644 --- a/processor/spanprocessor/factory_test.go +++ b/processor/spanprocessor/factory_test.go @@ -53,7 +53,7 @@ func TestFactory_CreateTraceProcessor(t *testing.T) { // Name.FromAttributes field needs to be set for the configuration to be valid. oCfg.Rename.FromAttributes = []string{"test-key"} - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) assert.NotNil(t, tp) @@ -90,7 +90,7 @@ func TestFactory_CreateTraceProcessor_InvalidConfig(t *testing.T) { cfg := factory.CreateDefaultConfig().(*Config) cfg.Rename = test.cfg - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) require.Nil(t, tp) assert.EqualValues(t, err, test.err) }) diff --git a/processor/spanprocessor/span_test.go b/processor/spanprocessor/span_test.go index df4fe1b5b27..22cdbf526be 100644 --- a/processor/spanprocessor/span_test.go +++ b/processor/spanprocessor/span_test.go @@ -41,7 +41,7 @@ func TestNewTraceProcessor(t *testing.T) { require.Error(t, componenterror.ErrNilNextConsumer, err) require.Nil(t, tp) - tp, err = factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop()) + tp, err = factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) } @@ -133,7 +133,7 @@ func TestSpanProcessor_NilEmptyData(t *testing.T) { } oCfg.Rename.FromAttributes = []string{"key"} - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) for i := range testCases { @@ -237,7 +237,7 @@ func TestSpanProcessor_Values(t *testing.T) { oCfg := cfg.(*Config) oCfg.Rename.FromAttributes = []string{"key1"} - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) for _, tc := range testCases { @@ -313,7 +313,7 @@ func TestSpanProcessor_MissingKeys(t *testing.T) { oCfg.Rename.FromAttributes = []string{"key1", "key2", "key3", "key4"} oCfg.Rename.Separator = "::" - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) for _, tc := range testCases { @@ -331,7 +331,7 @@ func TestSpanProcessor_Separator(t *testing.T) { oCfg.Rename.FromAttributes = []string{"key1"} oCfg.Rename.Separator = "::" - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -360,7 +360,7 @@ func TestSpanProcessor_NoSeparatorMultipleKeys(t *testing.T) { oCfg.Rename.FromAttributes = []string{"key1", "key2"} oCfg.Rename.Separator = "" - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -390,7 +390,7 @@ func TestSpanProcessor_SeparatorMultipleKeys(t *testing.T) { oCfg.Rename.FromAttributes = []string{"key1", "key2", "key3", "key4"} oCfg.Rename.Separator = "::" - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -425,7 +425,7 @@ func TestSpanProcessor_NilName(t *testing.T) { oCfg.Rename.FromAttributes = []string{"key1"} oCfg.Rename.Separator = "::" - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -522,7 +522,7 @@ func TestSpanProcessor_ToAttributes(t *testing.T) { for _, tc := range testCases { oCfg.Rename.ToAttributes.Rules = tc.rules oCfg.Rename.ToAttributes.BreakAfterMatch = tc.breakAfterMatch - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) @@ -589,7 +589,7 @@ func TestSpanProcessor_skipSpan(t *testing.T) { oCfg.Rename.ToAttributes = &ToAttributes{ Rules: []string{`(?P.*?)$`}, } - tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop()) + tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNop()) require.Nil(t, err) require.NotNil(t, tp) diff --git a/receiver/hostmetricsreceiver/factory_test.go b/receiver/hostmetricsreceiver/factory_test.go index ebb478bbcef..fd1ce46429d 100644 --- a/receiver/hostmetricsreceiver/factory_test.go +++ b/receiver/hostmetricsreceiver/factory_test.go @@ -42,15 +42,15 @@ func TestCreateReceiver(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - tReceiver, err := factory.CreateTracesReceiver(context.Background(), creationParams, cfg, consumertest.NewTracesNop()) + tReceiver, err := factory.CreateTracesReceiver(context.Background(), creationParams, cfg, consumertest.NewNop()) assert.Equal(t, err, configerror.ErrDataTypeIsNotSupported) assert.Nil(t, tReceiver) - mReceiver, err := factory.CreateMetricsReceiver(context.Background(), creationParams, cfg, consumertest.NewMetricsNop()) + mReceiver, err := factory.CreateMetricsReceiver(context.Background(), creationParams, cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, mReceiver) - tLogs, err := factory.CreateLogsReceiver(context.Background(), creationParams, cfg, consumertest.NewLogsNop()) + tLogs, err := factory.CreateLogsReceiver(context.Background(), creationParams, cfg, consumertest.NewNop()) assert.Equal(t, err, configerror.ErrDataTypeIsNotSupported) assert.Nil(t, tLogs) } @@ -61,6 +61,6 @@ func TestCreateReceiver_ScraperKeyConfigError(t *testing.T) { factory := NewFactory() cfg := &Config{Scrapers: map[string]internal.Config{errorKey: &mockConfig{}}} - _, err := factory.CreateMetricsReceiver(context.Background(), creationParams, cfg, consumertest.NewMetricsNop()) + _, err := factory.CreateMetricsReceiver(context.Background(), creationParams, cfg, consumertest.NewNop()) assert.EqualError(t, err, fmt.Sprintf("host metrics scraper factory not found for key: %q", errorKey)) } diff --git a/receiver/jaegerreceiver/trace_receiver_test.go b/receiver/jaegerreceiver/trace_receiver_test.go index 4da4298096d..46689f2b037 100644 --- a/receiver/jaegerreceiver/trace_receiver_test.go +++ b/receiver/jaegerreceiver/trace_receiver_test.go @@ -527,7 +527,7 @@ func TestSamplingStrategiesMutualTLS(t *testing.T) { cfg.Protocols.ThriftHTTP = &confighttp.HTTPServerSettings{ Endpoint: fmt.Sprintf("localhost:%d", thriftHTTPPort), } - exp, err := factory.CreateTracesReceiver(context.Background(), component.ReceiverCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewTracesNop()) + exp, err := factory.CreateTracesReceiver(context.Background(), component.ReceiverCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNop()) require.NoError(t, err) err = exp.Start(context.Background(), newAssertNoErrorHost(t)) require.NoError(t, err) @@ -555,7 +555,7 @@ func TestConsumeThriftTrace(t *testing.T) { }, } for _, test := range tests { - numSpans, err := consumeTraces(context.Background(), test.batch, consumertest.NewTracesNop()) + numSpans, err := consumeTraces(context.Background(), test.batch, consumertest.NewNop()) require.NoError(t, err) assert.Equal(t, test.numSpans, numSpans) } diff --git a/receiver/kafkareceiver/kafka_receiver_test.go b/receiver/kafkareceiver/kafka_receiver_test.go index c914da0f8ea..9100d4fe7c4 100644 --- a/receiver/kafkareceiver/kafka_receiver_test.go +++ b/receiver/kafkareceiver/kafka_receiver_test.go @@ -42,7 +42,7 @@ func TestNewReceiver_version_err(t *testing.T) { Encoding: defaultEncoding, ProtocolVersion: "none", } - r, err := newReceiver(c, component.ReceiverCreateParams{}, defaultUnmarshallers(), consumertest.NewTracesNop()) + r, err := newReceiver(c, component.ReceiverCreateParams{}, defaultUnmarshallers(), consumertest.NewNop()) assert.Error(t, err) assert.Nil(t, r) } @@ -51,7 +51,7 @@ func TestNewReceiver_encoding_err(t *testing.T) { c := Config{ Encoding: "foo", } - r, err := newReceiver(c, component.ReceiverCreateParams{}, defaultUnmarshallers(), consumertest.NewTracesNop()) + r, err := newReceiver(c, component.ReceiverCreateParams{}, defaultUnmarshallers(), consumertest.NewNop()) require.Error(t, err) assert.Nil(t, r) assert.EqualError(t, err, errUnrecognizedEncoding.Error()) @@ -72,7 +72,7 @@ func TestNewExporter_err_auth_type(t *testing.T) { Full: false, }, } - r, err := newReceiver(c, component.ReceiverCreateParams{}, defaultUnmarshallers(), consumertest.NewTracesNop()) + r, err := newReceiver(c, component.ReceiverCreateParams{}, defaultUnmarshallers(), consumertest.NewNop()) assert.Error(t, err) assert.Contains(t, err.Error(), "failed to load TLS config") assert.Nil(t, r) @@ -81,7 +81,7 @@ func TestNewExporter_err_auth_type(t *testing.T) { func TestReceiverStart(t *testing.T) { testClient := testConsumerGroup{once: &sync.Once{}} c := kafkaConsumer{ - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), logger: zap.NewNop(), consumerGroup: testClient, } @@ -94,7 +94,7 @@ func TestReceiverStart(t *testing.T) { func TestReceiverStartConsume(t *testing.T) { testClient := testConsumerGroup{once: &sync.Once{}} c := kafkaConsumer{ - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), logger: zap.NewNop(), consumerGroup: testClient, } @@ -114,7 +114,7 @@ func TestReceiver_error(t *testing.T) { expectedErr := fmt.Errorf("handler error") testClient := testConsumerGroup{once: &sync.Once{}, err: expectedErr} c := kafkaConsumer{ - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), logger: logger, consumerGroup: testClient, } @@ -137,7 +137,7 @@ func TestConsumerGroupHandler(t *testing.T) { unmarshaller: &otlpTracesPbUnmarshaller{}, logger: zap.NewNop(), ready: make(chan bool), - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), } testSession := testConsumerGroupSession{} @@ -181,7 +181,7 @@ func TestConsumerGroupHandler_error_unmarshall(t *testing.T) { unmarshaller: &otlpTracesPbUnmarshaller{}, logger: zap.NewNop(), ready: make(chan bool), - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), } wg := sync.WaitGroup{} @@ -205,7 +205,7 @@ func TestConsumerGroupHandler_error_nextConsumer(t *testing.T) { unmarshaller: &otlpTracesPbUnmarshaller{}, logger: zap.NewNop(), ready: make(chan bool), - nextConsumer: consumertest.NewTracesErr(consumerError), + nextConsumer: consumertest.NewErr(consumerError), } wg := sync.WaitGroup{} diff --git a/receiver/opencensusreceiver/factory_test.go b/receiver/opencensusreceiver/factory_test.go index 9536cc3a8f9..e72e42ee7ef 100644 --- a/receiver/opencensusreceiver/factory_test.go +++ b/receiver/opencensusreceiver/factory_test.go @@ -111,7 +111,7 @@ func TestCreateTraceReceiver(t *testing.T) { params := component.ReceiverCreateParams{Logger: zap.NewNop()} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - tr, err := createTraceReceiver(ctx, params, tt.cfg, consumertest.NewTracesNop()) + tr, err := createTraceReceiver(ctx, params, tt.cfg, consumertest.NewNop()) if (err != nil) != tt.wantErr { t.Errorf("factory.CreateTracesReceiver() error = %v, wantErr %v", err, tt.wantErr) return @@ -187,7 +187,7 @@ func TestCreateMetricReceiver(t *testing.T) { params := component.ReceiverCreateParams{Logger: zap.NewNop()} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - tc, err := createMetricsReceiver(context.Background(), params, tt.cfg, consumertest.NewMetricsNop()) + tc, err := createMetricsReceiver(context.Background(), params, tt.cfg, consumertest.NewNop()) if (err != nil) != tt.wantErr { t.Errorf("factory.CreateMetricsReceiver() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/receiver/opencensusreceiver/octrace/observability_test.go b/receiver/opencensusreceiver/octrace/observability_test.go index 15071f89315..02608a7d6dd 100644 --- a/receiver/opencensusreceiver/octrace/observability_test.go +++ b/receiver/opencensusreceiver/octrace/observability_test.go @@ -44,7 +44,7 @@ func TestEnsureRecordedMetrics(t *testing.T) { require.NoError(t, err) defer doneFn() - port, doneReceiverFn := ocReceiverOnGRPCServer(t, consumertest.NewTracesNop()) + port, doneReceiverFn := ocReceiverOnGRPCServer(t, consumertest.NewNop()) defer doneReceiverFn() n := 20 @@ -66,7 +66,7 @@ func TestEnsureRecordedMetrics_zeroLengthSpansSender(t *testing.T) { require.NoError(t, err) defer doneFn() - port, doneFn := ocReceiverOnGRPCServer(t, consumertest.NewTracesNop()) + port, doneFn := ocReceiverOnGRPCServer(t, consumertest.NewNop()) defer doneFn() n := 20 @@ -96,7 +96,7 @@ func TestExportSpanLinkingMaintainsParentLink(t *testing.T) { trace.RegisterExporter(ocSpansSaver) defer trace.UnregisterExporter(ocSpansSaver) - port, doneFn := ocReceiverOnGRPCServer(t, consumertest.NewTracesNop()) + port, doneFn := ocReceiverOnGRPCServer(t, consumertest.NewNop()) defer doneFn() traceSvcClient, traceSvcDoneFn, err := makeTraceServiceClient(port) diff --git a/receiver/opencensusreceiver/opencensus_test.go b/receiver/opencensusreceiver/opencensus_test.go index 07e16b12290..6521b26d510 100644 --- a/receiver/opencensusreceiver/opencensus_test.go +++ b/receiver/opencensusreceiver/opencensus_test.go @@ -155,7 +155,7 @@ func TestTraceGrpcGatewayCors_endToEnd(t *testing.T) { addr := testutil.GetAvailableLocalAddress(t) corsOrigins := []string{"allowed-*.com"} - ocr, err := newOpenCensusReceiver(ocReceiverName, "tcp", addr, consumertest.NewTracesNop(), nil, withCorsOrigins(corsOrigins)) + ocr, err := newOpenCensusReceiver(ocReceiverName, "tcp", addr, consumertest.NewNop(), nil, withCorsOrigins(corsOrigins)) require.NoError(t, err, "Failed to create trace receiver: %v", err) defer ocr.Shutdown(context.Background()) @@ -179,7 +179,7 @@ func TestMetricsGrpcGatewayCors_endToEnd(t *testing.T) { addr := testutil.GetAvailableLocalAddress(t) corsOrigins := []string{"allowed-*.com"} - ocr, err := newOpenCensusReceiver(ocReceiverName, "tcp", addr, nil, consumertest.NewMetricsNop(), withCorsOrigins(corsOrigins)) + ocr, err := newOpenCensusReceiver(ocReceiverName, "tcp", addr, nil, consumertest.NewNop(), withCorsOrigins(corsOrigins)) require.NoError(t, err, "Failed to create metrics receiver: %v", err) defer ocr.Shutdown(context.Background()) @@ -257,7 +257,7 @@ func TestNewPortAlreadyUsed(t *testing.T) { func TestMultipleStopReceptionShouldNotError(t *testing.T) { addr := testutil.GetAvailableLocalAddress(t) - r, err := newOpenCensusReceiver(ocReceiverName, "tcp", addr, consumertest.NewTracesNop(), consumertest.NewMetricsNop()) + r, err := newOpenCensusReceiver(ocReceiverName, "tcp", addr, consumertest.NewNop(), consumertest.NewNop()) require.NoError(t, err) require.NotNil(t, r) @@ -285,7 +285,7 @@ func tempSocketName(t *testing.T) string { func TestReceiveOnUnixDomainSocket_endToEnd(t *testing.T) { socketName := tempSocketName(t) - cbts := consumertest.NewTracesNop() + cbts := consumertest.NewNop() r, err := newOpenCensusReceiver(ocReceiverName, "unix", socketName, cbts, nil) require.NoError(t, err) require.NotNil(t, r) diff --git a/receiver/otlpreceiver/logs/otlp_test.go b/receiver/otlpreceiver/logs/otlp_test.go index 07f313c957c..b3ba55c4cea 100644 --- a/receiver/otlpreceiver/logs/otlp_test.go +++ b/receiver/otlpreceiver/logs/otlp_test.go @@ -105,7 +105,7 @@ func TestExport_EmptyRequest(t *testing.T) { } func TestExport_ErrorConsumer(t *testing.T) { - port, doneFn := otlpReceiverOnGRPCServer(t, consumertest.NewLogsErr(errors.New("my error"))) + port, doneFn := otlpReceiverOnGRPCServer(t, consumertest.NewErr(errors.New("my error"))) defer doneFn() logClient, logClientDoneFn, err := makeLogsServiceClient(port) diff --git a/receiver/otlpreceiver/metrics/otlp_test.go b/receiver/otlpreceiver/metrics/otlp_test.go index e7f82dbcfe3..7fb535cf5be 100644 --- a/receiver/otlpreceiver/metrics/otlp_test.go +++ b/receiver/otlpreceiver/metrics/otlp_test.go @@ -139,7 +139,7 @@ func TestExport_EmptyRequest(t *testing.T) { func TestExport_ErrorConsumer(t *testing.T) { // given - port, doneFn := otlpReceiverOnGRPCServer(t, consumertest.NewMetricsErr(errors.New("my error"))) + port, doneFn := otlpReceiverOnGRPCServer(t, consumertest.NewErr(errors.New("my error"))) defer doneFn() metricsClient, metricsClientDoneFn, err := makeMetricsServiceClient(port) diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 78b9a559b9c..e25d7ba865f 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -339,7 +339,7 @@ func TestProtoHttp(t *testing.T) { // Set the buffer count to 1 to make it flush the test span immediately. tSink := &internalconsumertest.ErrOrSinkConsumer{TracesSink: new(consumertest.TracesSink)} - ocr := newHTTPReceiver(t, addr, tSink, consumertest.NewMetricsNop()) + ocr := newHTTPReceiver(t, addr, tSink, consumertest.NewNop()) require.NoError(t, ocr.Start(context.Background(), componenttest.NewNopHost()), "Failed to start trace receiver") defer ocr.Shutdown(context.Background()) diff --git a/receiver/otlpreceiver/trace/otlp_test.go b/receiver/otlpreceiver/trace/otlp_test.go index e2925a6af5f..b2fbd5236b0 100644 --- a/receiver/otlpreceiver/trace/otlp_test.go +++ b/receiver/otlpreceiver/trace/otlp_test.go @@ -109,7 +109,7 @@ func TestExport_EmptyRequest(t *testing.T) { } func TestExport_ErrorConsumer(t *testing.T) { - port, doneFn := otlpReceiverOnGRPCServer(t, consumertest.NewTracesErr(errors.New("my error"))) + port, doneFn := otlpReceiverOnGRPCServer(t, consumertest.NewErr(errors.New("my error"))) defer doneFn() traceClient, traceClientDoneFn, err := makeTraceServiceClient(port) diff --git a/receiver/prometheusreceiver/internal/transaction_test.go b/receiver/prometheusreceiver/internal/transaction_test.go index d52737c7fb6..989dc4e8bc9 100644 --- a/receiver/prometheusreceiver/internal/transaction_test.go +++ b/receiver/prometheusreceiver/internal/transaction_test.go @@ -62,7 +62,7 @@ func Test_transaction(t *testing.T) { rn := "prometheus" t.Run("Commit Without Adding", func(t *testing.T) { - nomc := consumertest.NewMetricsNop() + nomc := consumertest.NewNop() tr := newTransaction(context.Background(), nil, true, "", rn, ms, nomc, testLogger) if got := tr.Commit(); got != nil { t.Errorf("expecting nil from Commit() but got err %v", got) @@ -70,7 +70,7 @@ func Test_transaction(t *testing.T) { }) t.Run("Rollback dose nothing", func(t *testing.T) { - nomc := consumertest.NewMetricsNop() + nomc := consumertest.NewNop() tr := newTransaction(context.Background(), nil, true, "", rn, ms, nomc, testLogger) if got := tr.Rollback(); got != nil { t.Errorf("expecting nil from Rollback() but got err %v", got) @@ -79,7 +79,7 @@ func Test_transaction(t *testing.T) { badLabels := labels.Labels([]labels.Label{{Name: "foo", Value: "bar"}}) t.Run("Add One No Target", func(t *testing.T) { - nomc := consumertest.NewMetricsNop() + nomc := consumertest.NewNop() tr := newTransaction(context.Background(), nil, true, "", rn, ms, nomc, testLogger) if _, got := tr.Add(badLabels, time.Now().Unix()*1000, 1.0); got == nil { t.Errorf("expecting error from Add() but got nil") @@ -91,7 +91,7 @@ func Test_transaction(t *testing.T) { {Name: "job", Value: "test2"}, {Name: "foo", Value: "bar"}}) t.Run("Add One Job not found", func(t *testing.T) { - nomc := consumertest.NewMetricsNop() + nomc := consumertest.NewNop() tr := newTransaction(context.Background(), nil, true, "", rn, ms, nomc, testLogger) if _, got := tr.Add(jobNotFoundLb, time.Now().Unix()*1000, 1.0); got == nil { t.Errorf("expecting error from Add() but got nil") diff --git a/receiver/zipkinreceiver/factory_test.go b/receiver/zipkinreceiver/factory_test.go index db1d1fe85b4..a85986f80c8 100644 --- a/receiver/zipkinreceiver/factory_test.go +++ b/receiver/zipkinreceiver/factory_test.go @@ -39,7 +39,7 @@ func TestCreateReceiver(t *testing.T) { context.Background(), component.ReceiverCreateParams{Logger: zap.NewNop()}, cfg, - consumertest.NewTracesNop()) + consumertest.NewNop()) assert.NoError(t, err, "receiver creation failed") assert.NotNil(t, tReceiver, "receiver creation failed") @@ -47,7 +47,7 @@ func TestCreateReceiver(t *testing.T) { context.Background(), component.ReceiverCreateParams{Logger: zap.NewNop()}, cfg, - consumertest.NewTracesNop()) + consumertest.NewNop()) assert.NoError(t, err, "receiver creation failed") assert.NotNil(t, tReceiver, "receiver creation failed") } diff --git a/receiver/zipkinreceiver/trace_receiver_test.go b/receiver/zipkinreceiver/trace_receiver_test.go index f085cb24272..eae4196be4f 100644 --- a/receiver/zipkinreceiver/trace_receiver_test.go +++ b/receiver/zipkinreceiver/trace_receiver_test.go @@ -69,7 +69,7 @@ func TestNew(t *testing.T) { { name: "happy path", args: args{ - nextConsumer: consumertest.NewTracesNop(), + nextConsumer: consumertest.NewNop(), }, }, } @@ -108,7 +108,7 @@ func TestZipkinReceiverPortAlreadyInUse(t *testing.T) { Endpoint: "localhost:" + portStr, }, } - traceReceiver, err := New(cfg, consumertest.NewTracesNop()) + traceReceiver, err := New(cfg, consumertest.NewNop()) require.NoError(t, err, "Failed to create receiver: %v", err) err = traceReceiver.Start(context.Background(), componenttest.NewNopHost()) require.Error(t, err) @@ -207,7 +207,7 @@ func TestConversionRoundtrip(t *testing.T) { } }]`) - zi := &ZipkinReceiver{nextConsumer: consumertest.NewTracesNop()} + zi := &ZipkinReceiver{nextConsumer: consumertest.NewNop()} zi.config = &Config{} ereqs, err := zi.v2ToTraceSpans(receiverInputJSON, nil) require.NoError(t, err) diff --git a/service/defaultcomponents/default_processors_test.go b/service/defaultcomponents/default_processors_test.go index a2d0e7863b7..3b3da9d673c 100644 --- a/service/defaultcomponents/default_processors_test.go +++ b/service/defaultcomponents/default_processors_test.go @@ -156,18 +156,18 @@ type createProcessorFn func( func wrapCreateLogsProc(factory component.ProcessorFactory) createProcessorFn { return func(ctx context.Context, params component.ProcessorCreateParams, cfg config.Processor) (component.Processor, error) { - return factory.CreateLogsProcessor(ctx, params, cfg, consumertest.NewLogsNop()) + return factory.CreateLogsProcessor(ctx, params, cfg, consumertest.NewNop()) } } func wrapCreateMetricsProc(factory component.ProcessorFactory) createProcessorFn { return func(ctx context.Context, params component.ProcessorCreateParams, cfg config.Processor) (component.Processor, error) { - return factory.CreateMetricsProcessor(ctx, params, cfg, consumertest.NewMetricsNop()) + return factory.CreateMetricsProcessor(ctx, params, cfg, consumertest.NewNop()) } } func wrapCreateTracesProc(factory component.ProcessorFactory) createProcessorFn { return func(ctx context.Context, params component.ProcessorCreateParams, cfg config.Processor) (component.Processor, error) { - return factory.CreateTracesProcessor(ctx, params, cfg, consumertest.NewTracesNop()) + return factory.CreateTracesProcessor(ctx, params, cfg, consumertest.NewNop()) } } diff --git a/service/defaultcomponents/default_receivers_test.go b/service/defaultcomponents/default_receivers_test.go index 0919e4769d1..62ac571ab4f 100644 --- a/service/defaultcomponents/default_receivers_test.go +++ b/service/defaultcomponents/default_receivers_test.go @@ -145,18 +145,18 @@ type createReceiverFn func( func wrapCreateLogsRcvr(factory component.ReceiverFactory) createReceiverFn { return func(ctx context.Context, params component.ReceiverCreateParams, cfg config.Receiver) (component.Receiver, error) { - return factory.CreateLogsReceiver(ctx, params, cfg, consumertest.NewLogsNop()) + return factory.CreateLogsReceiver(ctx, params, cfg, consumertest.NewNop()) } } func wrapCreateMetricsRcvr(factory component.ReceiverFactory) createReceiverFn { return func(ctx context.Context, params component.ReceiverCreateParams, cfg config.Receiver) (component.Receiver, error) { - return factory.CreateMetricsReceiver(ctx, params, cfg, consumertest.NewMetricsNop()) + return factory.CreateMetricsReceiver(ctx, params, cfg, consumertest.NewNop()) } } func wrapCreateTracesRcvr(factory component.ReceiverFactory) createReceiverFn { return func(ctx context.Context, params component.ReceiverCreateParams, cfg config.Receiver) (component.Receiver, error) { - return factory.CreateTracesReceiver(ctx, params, cfg, consumertest.NewTracesNop()) + return factory.CreateTracesReceiver(ctx, params, cfg, consumertest.NewNop()) } } From b348f3a9d10b7ad4f7996ab5f8a4fd49b91a8e24 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Fri, 2 Apr 2021 13:52:58 -0700 Subject: [PATCH 2/2] Add changelog entry, fix license Signed-off-by: Bogdan Drutu --- CHANGELOG.md | 2 ++ consumer/consumertest/consumer.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fafc6ebf5d..ebfda3c7175 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ - `batch` processor: - Support max batch size for logs (#2736) - Use `Endpoint` for health check extension (#2782) - Use `confignet.TCPAddr` for `pprof` and `zpages` extensions (#2829) +- Deprecate `consumetest.New[${SIGNAL}]Nop` in favor of `consumetest.NewNop` (#2878) +- Deprecate `consumetest.New[${SIGNAL}]Err` in favor of `consumetest.NewErr` (#2878) ## 🧰 Bug fixes 🧰 diff --git a/consumer/consumertest/consumer.go b/consumer/consumertest/consumer.go index c5108f14ca3..f23e028ff41 100644 --- a/consumer/consumertest/consumer.go +++ b/consumer/consumertest/consumer.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package consumertest import (