diff --git a/.chloggen/deprecatecompexp.yaml b/.chloggen/deprecatecompexp.yaml index 4e4e099243e..3ef48e46a88 100755 --- a/.chloggen/deprecatecompexp.yaml +++ b/.chloggen/deprecatecompexp.yaml @@ -22,4 +22,4 @@ subtext: |- - `component.NewExporterFactory` -> `exporter.NewFactory` - `component.MakeExporterFactoryMap` -> `exporter.MakeFactoryMap` - `componenttest.NewNopExporterCreateSettings` -> `exportertest.NewNopCreateSettings` - - `componenttest.NewNopExporterFactory` -> `exportertest.NewNopFactory` \ No newline at end of file + - `componenttest.NewNopExporterFactory` -> `exportertest.NewNopFactory` diff --git a/component/componenttest/nop_exporter.go b/component/componenttest/nop_exporter.go index ac038d4130f..b0e3b1ee2a5 100644 --- a/component/componenttest/nop_exporter.go +++ b/component/componenttest/nop_exporter.go @@ -23,7 +23,7 @@ import ( "go.opentelemetry.io/collector/exporter" ) -// NewNopExporterCreateSettings returns a new nop settings for Create*Exporter functions. +// Deprecated: [v0.67.0] use exportertest.NewNopCreateSettings. func NewNopExporterCreateSettings() exporter.CreateSettings { return exporter.CreateSettings{ TelemetrySettings: NewNopTelemetrySettings(), @@ -35,7 +35,7 @@ type nopExporterConfig struct { config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct } -// NewNopExporterFactory returns an exporter.Factory that constructs nop exporters. +// Deprecated: [v0.67.0] use exportertest.NewNopFactory. func NewNopExporterFactory() exporter.Factory { return exporter.NewFactory( "nop", diff --git a/exporter/exporterhelper/common_test.go b/exporter/exporterhelper/common_test.go index 0937bf34815..ed0a623516b 100644 --- a/exporter/exporterhelper/common_test.go +++ b/exporter/exporterhelper/common_test.go @@ -28,13 +28,14 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper/internal" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/pdata/ptrace" ) var ( defaultID = component.NewID("test") defaultSettings = func() exporter.CreateSettings { - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() set.ID = defaultID return set }() diff --git a/exporter/exporterhelper/logs_test.go b/exporter/exporterhelper/logs_test.go index 44148860fba..c74af4e96db 100644 --- a/exporter/exporterhelper/logs_test.go +++ b/exporter/exporterhelper/logs_test.go @@ -32,6 +32,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics" "go.opentelemetry.io/collector/internal/testdata" "go.opentelemetry.io/collector/obsreport/obsreporttest" @@ -60,7 +61,7 @@ func TestLogsRequest(t *testing.T) { } func TestLogsExporter_InvalidName(t *testing.T) { - le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), nil, newPushLogsData(nil)) + le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), nil, newPushLogsData(nil)) require.Nil(t, le) require.Equal(t, errNilConfig, err) } @@ -72,14 +73,14 @@ func TestLogsExporter_NilLogger(t *testing.T) { } func TestLogsExporter_NilPushLogsData(t *testing.T) { - le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, nil) + le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, nil) require.Nil(t, le) require.Equal(t, errNilPushLogsData, err) } func TestLogsExporter_Default(t *testing.T) { ld := plog.NewLogs() - le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil)) + le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil)) assert.NotNil(t, le) assert.NoError(t, err) @@ -91,7 +92,7 @@ func TestLogsExporter_Default(t *testing.T) { func TestLogsExporter_WithCapabilities(t *testing.T) { capabilities := consumer.Capabilities{MutatesData: true} - le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithCapabilities(capabilities)) + le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithCapabilities(capabilities)) require.NoError(t, err) require.NotNil(t, le) @@ -101,7 +102,7 @@ func TestLogsExporter_WithCapabilities(t *testing.T) { func TestLogsExporter_Default_ReturnError(t *testing.T) { ld := plog.NewLogs() want := errors.New("my_error") - le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(want)) + le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(want)) require.NoError(t, err) require.NotNil(t, le) require.Equal(t, want, le.ConsumeLogs(context.Background(), ld)) @@ -158,7 +159,7 @@ func TestLogsExporter_WithRecordEnqueueFailedMetrics(t *testing.T) { } func TestLogsExporter_WithSpan(t *testing.T) { - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() sr := new(tracetest.SpanRecorder) set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) otel.SetTracerProvider(set.TracerProvider) @@ -171,7 +172,7 @@ func TestLogsExporter_WithSpan(t *testing.T) { } func TestLogsExporter_WithSpan_ReturnError(t *testing.T) { - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() sr := new(tracetest.SpanRecorder) set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) otel.SetTracerProvider(set.TracerProvider) @@ -188,7 +189,7 @@ func TestLogsExporter_WithShutdown(t *testing.T) { shutdownCalled := false shutdown := func(context.Context) error { shutdownCalled = true; return nil } - le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithShutdown(shutdown)) + le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithShutdown(shutdown)) assert.NotNil(t, le) assert.NoError(t, err) @@ -200,7 +201,7 @@ func TestLogsExporter_WithShutdown_ReturnError(t *testing.T) { want := errors.New("my_error") shutdownErr := func(context.Context) error { return want } - le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithShutdown(shutdownErr)) + le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithShutdown(shutdownErr)) assert.NotNil(t, le) assert.NoError(t, err) diff --git a/exporter/exporterhelper/metrics_test.go b/exporter/exporterhelper/metrics_test.go index 83d091c32c2..910c0424898 100644 --- a/exporter/exporterhelper/metrics_test.go +++ b/exporter/exporterhelper/metrics_test.go @@ -32,6 +32,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics" "go.opentelemetry.io/collector/internal/testdata" "go.opentelemetry.io/collector/obsreport/obsreporttest" @@ -59,7 +60,7 @@ func TestMetricsRequest(t *testing.T) { } func TestMetricsExporter_InvalidName(t *testing.T) { - me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), nil, newPushMetricsData(nil)) + me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), nil, newPushMetricsData(nil)) require.Nil(t, me) require.Equal(t, errNilConfig, err) } @@ -71,14 +72,14 @@ func TestMetricsExporter_NilLogger(t *testing.T) { } func TestMetricsExporter_NilPushMetricsData(t *testing.T) { - me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, nil) + me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, nil) require.Nil(t, me) require.Equal(t, errNilPushMetricsData, err) } func TestMetricsExporter_Default(t *testing.T) { md := pmetric.NewMetrics() - me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil)) + me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil)) assert.NoError(t, err) assert.NotNil(t, me) @@ -90,7 +91,7 @@ func TestMetricsExporter_Default(t *testing.T) { func TestMetricsExporter_WithCapabilities(t *testing.T) { capabilities := consumer.Capabilities{MutatesData: true} - me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithCapabilities(capabilities)) + me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithCapabilities(capabilities)) assert.NoError(t, err) assert.NotNil(t, me) @@ -100,7 +101,7 @@ func TestMetricsExporter_WithCapabilities(t *testing.T) { func TestMetricsExporter_Default_ReturnError(t *testing.T) { md := pmetric.NewMetrics() want := errors.New("my_error") - me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(want)) + me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(want)) require.NoError(t, err) require.NotNil(t, me) require.Equal(t, want, me.ConsumeMetrics(context.Background(), md)) @@ -157,7 +158,7 @@ func TestMetricsExporter_WithRecordEnqueueFailedMetrics(t *testing.T) { } func TestMetricsExporter_WithSpan(t *testing.T) { - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() sr := new(tracetest.SpanRecorder) set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) otel.SetTracerProvider(set.TracerProvider) @@ -170,7 +171,7 @@ func TestMetricsExporter_WithSpan(t *testing.T) { } func TestMetricsExporter_WithSpan_ReturnError(t *testing.T) { - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() sr := new(tracetest.SpanRecorder) set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) otel.SetTracerProvider(set.TracerProvider) @@ -187,7 +188,7 @@ func TestMetricsExporter_WithShutdown(t *testing.T) { shutdownCalled := false shutdown := func(context.Context) error { shutdownCalled = true; return nil } - me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithShutdown(shutdown)) + me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithShutdown(shutdown)) assert.NotNil(t, me) assert.NoError(t, err) @@ -200,7 +201,7 @@ func TestMetricsExporter_WithShutdown_ReturnError(t *testing.T) { want := errors.New("my_error") shutdownErr := func(context.Context) error { return want } - me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithShutdown(shutdownErr)) + me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithShutdown(shutdownErr)) assert.NotNil(t, me) assert.NoError(t, err) diff --git a/exporter/exporterhelper/traces_test.go b/exporter/exporterhelper/traces_test.go index 46cad9ff7ca..5455d71a1a4 100644 --- a/exporter/exporterhelper/traces_test.go +++ b/exporter/exporterhelper/traces_test.go @@ -32,6 +32,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics" "go.opentelemetry.io/collector/internal/testdata" "go.opentelemetry.io/collector/obsreport/obsreporttest" @@ -55,7 +56,7 @@ func TestTracesRequest(t *testing.T) { } func TestTracesExporter_InvalidName(t *testing.T) { - te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), nil, newTraceDataPusher(nil)) + te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), nil, newTraceDataPusher(nil)) require.Nil(t, te) require.Equal(t, errNilConfig, err) } @@ -67,14 +68,14 @@ func TestTracesExporter_NilLogger(t *testing.T) { } func TestTracesExporter_NilPushTraceData(t *testing.T) { - te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, nil) + te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, nil) require.Nil(t, te) require.Equal(t, errNilPushTraceData, err) } func TestTracesExporter_Default(t *testing.T) { td := ptrace.NewTraces() - te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil)) + te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil)) assert.NotNil(t, te) assert.NoError(t, err) @@ -86,7 +87,7 @@ func TestTracesExporter_Default(t *testing.T) { func TestTracesExporter_WithCapabilities(t *testing.T) { capabilities := consumer.Capabilities{MutatesData: true} - te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithCapabilities(capabilities)) + te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithCapabilities(capabilities)) assert.NotNil(t, te) assert.NoError(t, err) @@ -96,7 +97,7 @@ func TestTracesExporter_WithCapabilities(t *testing.T) { func TestTracesExporter_Default_ReturnError(t *testing.T) { td := ptrace.NewTraces() want := errors.New("my_error") - te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(want)) + te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(want)) require.NoError(t, err) require.NotNil(t, te) @@ -155,7 +156,7 @@ func TestTracesExporter_WithRecordEnqueueFailedMetrics(t *testing.T) { } func TestTracesExporter_WithSpan(t *testing.T) { - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() sr := new(tracetest.SpanRecorder) set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) otel.SetTracerProvider(set.TracerProvider) @@ -169,7 +170,7 @@ func TestTracesExporter_WithSpan(t *testing.T) { } func TestTracesExporter_WithSpan_ReturnError(t *testing.T) { - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() sr := new(tracetest.SpanRecorder) set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) otel.SetTracerProvider(set.TracerProvider) @@ -187,7 +188,7 @@ func TestTracesExporter_WithShutdown(t *testing.T) { shutdownCalled := false shutdown := func(context.Context) error { shutdownCalled = true; return nil } - te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithShutdown(shutdown)) + te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithShutdown(shutdown)) assert.NotNil(t, te) assert.NoError(t, err) @@ -200,7 +201,7 @@ func TestTracesExporter_WithShutdown_ReturnError(t *testing.T) { want := errors.New("my_error") shutdownErr := func(context.Context) error { return want } - te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithShutdown(shutdownErr)) + te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithShutdown(shutdownErr)) assert.NotNil(t, te) assert.NoError(t, err) diff --git a/exporter/exportertest/nop_exporter.go b/exporter/exportertest/nop_exporter.go index 3a256b653bf..2be0e2be340 100644 --- a/exporter/exportertest/nop_exporter.go +++ b/exporter/exportertest/nop_exporter.go @@ -19,7 +19,7 @@ import ( ) // NewNopCreateSettings returns a new nop settings for Create*Exporter functions. -var NewNopCreateSettings = componenttest.NewNopExporterCreateSettings +var NewNopCreateSettings = componenttest.NewNopExporterCreateSettings //nolint:staticcheck // NewNopFactory returns an exporter.Factory that constructs nop exporters. -var NewNopFactory = componenttest.NewNopExporterFactory +var NewNopFactory = componenttest.NewNopExporterFactory //nolint:staticcheck diff --git a/exporter/exportertest/nop_exporter_test.go b/exporter/exportertest/nop_exporter_test.go index d0fa7aa4213..398cc5aa491 100644 --- a/exporter/exportertest/nop_exporter_test.go +++ b/exporter/exportertest/nop_exporter_test.go @@ -35,19 +35,19 @@ func TestNewNopFactory(t *testing.T) { cfg := factory.CreateDefaultConfig() // assert.Equal(t, &nopExporterConfig{ExporterSettings: config.NewExporterSettings(component.NewID("nop"))}, cfg) - traces, err := factory.CreateTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + traces, err := factory.CreateTracesExporter(context.Background(), NewNopCreateSettings(), cfg) require.NoError(t, err) assert.NoError(t, traces.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, traces.ConsumeTraces(context.Background(), ptrace.NewTraces())) assert.NoError(t, traces.Shutdown(context.Background())) - metrics, err := factory.CreateMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + metrics, err := factory.CreateMetricsExporter(context.Background(), NewNopCreateSettings(), cfg) require.NoError(t, err) assert.NoError(t, metrics.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.NoError(t, metrics.Shutdown(context.Background())) - logs, err := factory.CreateLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + logs, err := factory.CreateLogsExporter(context.Background(), NewNopCreateSettings(), cfg) require.NoError(t, err) assert.NoError(t, logs.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, logs.ConsumeLogs(context.Background(), plog.NewLogs())) diff --git a/exporter/loggingexporter/factory_test.go b/exporter/loggingexporter/factory_test.go index 5dac03d80cb..9dbb4e76e7c 100644 --- a/exporter/loggingexporter/factory_test.go +++ b/exporter/loggingexporter/factory_test.go @@ -21,6 +21,7 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/exporter/exportertest" ) func TestCreateDefaultConfig(t *testing.T) { @@ -34,7 +35,7 @@ func TestCreateMetricsExporter(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - me, err := factory.CreateMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + me, err := factory.CreateMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg) assert.NoError(t, err) assert.NotNil(t, me) } @@ -43,7 +44,7 @@ func TestCreateTracesExporter(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - te, err := factory.CreateTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + te, err := factory.CreateTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg) assert.NoError(t, err) assert.NotNil(t, te) } @@ -52,7 +53,7 @@ func TestCreateLogsExporter(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - te, err := factory.CreateLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + te, err := factory.CreateLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg) assert.NoError(t, err) assert.NotNil(t, te) } diff --git a/exporter/loggingexporter/logging_exporter_test.go b/exporter/loggingexporter/logging_exporter_test.go index afb09277900..0f435f45c10 100644 --- a/exporter/loggingexporter/logging_exporter_test.go +++ b/exporter/loggingexporter/logging_exporter_test.go @@ -22,8 +22,8 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config/configtelemetry" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/testdata" "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" @@ -32,7 +32,7 @@ import ( func TestLoggingTracesExporterNoErrors(t *testing.T) { f := NewFactory() - lte, err := f.CreateTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), f.CreateDefaultConfig()) + lte, err := f.CreateTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), f.CreateDefaultConfig()) require.NotNil(t, lte) assert.NoError(t, err) @@ -44,7 +44,7 @@ func TestLoggingTracesExporterNoErrors(t *testing.T) { func TestLoggingMetricsExporterNoErrors(t *testing.T) { f := NewFactory() - lme, err := f.CreateMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), f.CreateDefaultConfig()) + lme, err := f.CreateMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), f.CreateDefaultConfig()) require.NotNil(t, lme) assert.NoError(t, err) @@ -59,7 +59,7 @@ func TestLoggingMetricsExporterNoErrors(t *testing.T) { func TestLoggingLogsExporterNoErrors(t *testing.T) { f := NewFactory() - lle, err := f.CreateLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), f.CreateDefaultConfig()) + lle, err := f.CreateLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), f.CreateDefaultConfig()) require.NotNil(t, lle) assert.NoError(t, err) diff --git a/exporter/otlpexporter/factory_test.go b/exporter/otlpexporter/factory_test.go index 9505a9f7d90..250e46d135f 100644 --- a/exporter/otlpexporter/factory_test.go +++ b/exporter/otlpexporter/factory_test.go @@ -30,6 +30,7 @@ import ( "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/exporter/exporterhelper" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/testutil" ) @@ -51,7 +52,7 @@ func TestCreateMetricsExporter(t *testing.T) { cfg := factory.CreateDefaultConfig().(*Config) cfg.GRPCClientSettings.Endpoint = testutil.GetAvailableLocalAddress(t) - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() oexp, err := factory.CreateMetricsExporter(context.Background(), set, cfg) require.Nil(t, err) require.NotNil(t, oexp) @@ -195,7 +196,7 @@ func TestCreateTracesExporter(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { factory := NewFactory() - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() consumer, err := factory.CreateTracesExporter(context.Background(), set, &tt.config) if tt.mustFailOnCreate { assert.NotNil(t, err) @@ -225,7 +226,7 @@ func TestCreateLogsExporter(t *testing.T) { cfg := factory.CreateDefaultConfig().(*Config) cfg.GRPCClientSettings.Endpoint = testutil.GetAvailableLocalAddress(t) - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() oexp, err := factory.CreateLogsExporter(context.Background(), set, cfg) require.Nil(t, err) require.NotNil(t, oexp) diff --git a/exporter/otlpexporter/otlp_test.go b/exporter/otlpexporter/otlp_test.go index 706591c3d26..01b1980ed8f 100644 --- a/exporter/otlpexporter/otlp_test.go +++ b/exporter/otlpexporter/otlp_test.go @@ -38,6 +38,7 @@ import ( "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/exporter" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/testdata" "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/plog/plogotlp" @@ -223,7 +224,7 @@ func TestSendTraces(t *testing.T) { "header": "header-value", }, } - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() set.BuildInfo.Description = "Collector" set.BuildInfo.Version = "1.2.3test" exp, err := factory.CreateTracesExporter(context.Background(), set, cfg) @@ -319,7 +320,7 @@ func TestSendTracesWhenEndpointHasHttpScheme(t *testing.T) { if test.useTLS { cfg.GRPCClientSettings.TLSSetting.InsecureSkipVerify = true } - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() exp, err := factory.CreateTracesExporter(context.Background(), set, cfg) require.NoError(t, err) require.NotNil(t, exp) @@ -369,7 +370,7 @@ func TestSendMetrics(t *testing.T) { "header": "header-value", }, } - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() set.BuildInfo.Description = "Collector" set.BuildInfo.Version = "1.2.3test" exp, err := factory.CreateMetricsExporter(context.Background(), set, cfg) @@ -442,7 +443,7 @@ func TestSendTraceDataServerDownAndUp(t *testing.T) { // Do not rely on external retry logic here, if that is intended set InitialInterval to 100ms. WaitForReady: true, } - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() exp, err := factory.CreateTracesExporter(context.Background(), set, cfg) require.NoError(t, err) require.NotNil(t, exp) @@ -499,7 +500,7 @@ func TestSendTraceDataServerStartWhileRequest(t *testing.T) { Insecure: true, }, } - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() exp, err := factory.CreateTracesExporter(context.Background(), set, cfg) require.NoError(t, err) require.NotNil(t, exp) @@ -550,7 +551,7 @@ func TestSendTracesOnResourceExhaustion(t *testing.T) { Insecure: true, }, } - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() exp, err := factory.CreateTracesExporter(context.Background(), set, cfg) require.NoError(t, err) require.NotNil(t, exp) @@ -628,7 +629,7 @@ func TestSendLogData(t *testing.T) { Insecure: true, }, } - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() set.BuildInfo.Description = "Collector" set.BuildInfo.Version = "1.2.3test" exp, err := factory.CreateLogsExporter(context.Background(), set, cfg) diff --git a/exporter/otlphttpexporter/factory_test.go b/exporter/otlphttpexporter/factory_test.go index 16502c20273..6e24d5cda23 100644 --- a/exporter/otlphttpexporter/factory_test.go +++ b/exporter/otlphttpexporter/factory_test.go @@ -29,6 +29,7 @@ import ( "go.opentelemetry.io/collector/config/configcompression" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/configtls" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/testutil" ) @@ -54,7 +55,7 @@ func TestCreateMetricsExporter(t *testing.T) { cfg := factory.CreateDefaultConfig().(*Config) cfg.HTTPClientSettings.Endpoint = "http://" + testutil.GetAvailableLocalAddress(t) - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() oexp, err := factory.CreateMetricsExporter(context.Background(), set, cfg) require.Nil(t, err) require.NotNil(t, oexp) @@ -179,7 +180,7 @@ func TestCreateTracesExporter(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { factory := NewFactory() - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() consumer, err := factory.CreateTracesExporter(context.Background(), set, &tt.config) if tt.mustFailOnCreate { @@ -208,7 +209,7 @@ func TestCreateLogsExporter(t *testing.T) { cfg := factory.CreateDefaultConfig().(*Config) cfg.HTTPClientSettings.Endpoint = "http://" + testutil.GetAvailableLocalAddress(t) - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() oexp, err := factory.CreateLogsExporter(context.Background(), set, cfg) require.Nil(t, err) require.NotNil(t, oexp) diff --git a/exporter/otlphttpexporter/otlp_test.go b/exporter/otlphttpexporter/otlp_test.go index 3f566bf46f0..470fa2010f6 100644 --- a/exporter/otlphttpexporter/otlp_test.go +++ b/exporter/otlphttpexporter/otlp_test.go @@ -44,6 +44,7 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/testdata" "go.opentelemetry.io/collector/internal/testutil" "go.opentelemetry.io/collector/pdata/plog" @@ -60,7 +61,7 @@ func TestInvalidConfig(t *testing.T) { }, } f := NewFactory() - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() _, err := f.CreateTracesExporter(context.Background(), set, config) require.Error(t, err) _, err = f.CreateMetricsExporter(context.Background(), set, config) @@ -307,7 +308,7 @@ func startTracesExporter(t *testing.T, baseURL string, overrideURL string) expor factory := NewFactory() cfg := createExporterConfig(baseURL, factory.CreateDefaultConfig()) cfg.TracesEndpoint = overrideURL - exp, err := factory.CreateTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + exp, err := factory.CreateTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg) require.NoError(t, err) startAndCleanup(t, exp) return exp @@ -317,7 +318,7 @@ func startMetricsExporter(t *testing.T, baseURL string, overrideURL string) expo factory := NewFactory() cfg := createExporterConfig(baseURL, factory.CreateDefaultConfig()) cfg.MetricsEndpoint = overrideURL - exp, err := factory.CreateMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + exp, err := factory.CreateMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg) require.NoError(t, err) startAndCleanup(t, exp) return exp @@ -327,7 +328,7 @@ func startLogsExporter(t *testing.T, baseURL string, overrideURL string) exporte factory := NewFactory() cfg := createExporterConfig(baseURL, factory.CreateDefaultConfig()) cfg.LogsEndpoint = overrideURL - exp, err := factory.CreateLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + exp, err := factory.CreateLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg) require.NoError(t, err) startAndCleanup(t, exp) return exp @@ -491,7 +492,7 @@ func TestErrorResponses(t *testing.T) { // Create without QueueSettings and RetrySettings so that ConsumeTraces // returns the errors that we want to check immediately. } - exp, err := createTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg) + exp, err := createTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg) require.NoError(t, err) // start the exporter @@ -519,7 +520,7 @@ func TestErrorResponses(t *testing.T) { func TestUserAgent(t *testing.T) { addr := testutil.GetAvailableLocalAddress(t) - set := componenttest.NewNopExporterCreateSettings() + set := exportertest.NewNopCreateSettings() set.BuildInfo.Description = "Collector" set.BuildInfo.Version = "1.2.3test" diff --git a/otelcol/config_provider_test.go b/otelcol/config_provider_test.go index 43716fd365c..c44f91cba68 100644 --- a/otelcol/config_provider_test.go +++ b/otelcol/config_provider_test.go @@ -30,6 +30,7 @@ import ( "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/provider/fileprovider" "go.opentelemetry.io/collector/confmap/provider/yamlprovider" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/extension/extensiontest" "go.opentelemetry.io/collector/service" "go.opentelemetry.io/collector/service/telemetry" @@ -38,7 +39,7 @@ import ( var configNop = &Config{ Receivers: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopReceiverFactory().CreateDefaultConfig()}, Processors: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopProcessorFactory().CreateDefaultConfig()}, - Exporters: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopExporterFactory().CreateDefaultConfig()}, + Exporters: map[component.ID]component.Config{component.NewID("nop"): exportertest.NewNopFactory().CreateDefaultConfig()}, Extensions: map[component.ID]component.Config{component.NewID("nop"): extensiontest.NewNopFactory().CreateDefaultConfig()}, Service: service.ConfigService{ Extensions: []component.ID{component.NewID("nop")}, diff --git a/service/internal/configunmarshaler/exporters_test.go b/service/internal/configunmarshaler/exporters_test.go index 0b0223f1daf..3fe59585008 100644 --- a/service/internal/configunmarshaler/exporters_test.go +++ b/service/internal/configunmarshaler/exporters_test.go @@ -21,13 +21,13 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/exporter" + "go.opentelemetry.io/collector/exporter/exportertest" ) func TestExportersUnmarshal(t *testing.T) { - factories, err := exporter.MakeFactoryMap(componenttest.NewNopExporterFactory()) + factories, err := exporter.MakeFactoryMap(exportertest.NewNopFactory()) require.NoError(t, err) exps := NewExporters(factories) @@ -101,7 +101,7 @@ func TestExportersUnmarshalError(t *testing.T) { }, } - factories, err := exporter.MakeFactoryMap(componenttest.NewNopExporterFactory()) + factories, err := exporter.MakeFactoryMap(exportertest.NewNopFactory()) assert.NoError(t, err) for _, tt := range testCases { diff --git a/service/pipelines_test.go b/service/pipelines_test.go index 2a0ac393402..16734a1279a 100644 --- a/service/pipelines_test.go +++ b/service/pipelines_test.go @@ -28,6 +28,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/exporter" + "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal/testdata" "go.opentelemetry.io/collector/service/internal/testcomponents" ) @@ -290,7 +291,7 @@ func TestBuildPipelines(t *testing.T) { func TestBuildErrors(t *testing.T) { nopReceiverFactory := componenttest.NewNopReceiverFactory() nopProcessorFactory := componenttest.NewNopProcessorFactory() - nopExporterFactory := componenttest.NewNopExporterFactory() + nopExporterFactory := exportertest.NewNopFactory() badReceiverFactory := newBadReceiverFactory() badProcessorFactory := newBadProcessorFactory() badExporterFactory := newBadExporterFactory() @@ -606,7 +607,7 @@ func TestFailToStartAndShutdown(t *testing.T) { errExporterFactory := newErrExporterFactory() nopReceiverFactory := componenttest.NewNopReceiverFactory() nopProcessorFactory := componenttest.NewNopProcessorFactory() - nopExporterFactory := componenttest.NewNopExporterFactory() + nopExporterFactory := exportertest.NewNopFactory() set := pipelinesSettings{ Telemetry: componenttest.NewNopTelemetrySettings(),