diff --git a/exporter/exportertest/nop_exporter.go b/exporter/exportertest/nop_exporter.go index 285aaf78ad0..480ef7a0c59 100644 --- a/exporter/exportertest/nop_exporter.go +++ b/exporter/exportertest/nop_exporter.go @@ -60,3 +60,14 @@ type nopExporter struct { component.ShutdownFunc consumertest.Consumer } + +// NewNopBuilder returns an exporter.Builder that constructs nop receivers. +// +// Deprecated: this builder is being internalized within the service module, +// and will be removed soon. +func NewNopBuilder() *exporter.Builder { + nopFactory := NewNopFactory() + return exporter.NewBuilder( + map[component.ID]component.Config{component.NewID(nopType): nopFactory.CreateDefaultConfig()}, + map[component.Type]exporter.Factory{nopType: nopFactory}) +} diff --git a/exporter/exportertest/nop_exporter_test.go b/exporter/exportertest/nop_exporter_test.go index 4d66f49fa19..43a7f74d61b 100644 --- a/exporter/exportertest/nop_exporter_test.go +++ b/exporter/exportertest/nop_exporter_test.go @@ -42,3 +42,31 @@ func TestNewNopFactory(t *testing.T) { assert.NoError(t, logs.ConsumeLogs(context.Background(), plog.NewLogs())) assert.NoError(t, logs.Shutdown(context.Background())) } + +func TestNewNopBuilder(t *testing.T) { + builder := NewNopBuilder() + require.NotNil(t, builder) + + factory := NewNopFactory() + cfg := factory.CreateDefaultConfig() + set := NewNopSettings() + set.ID = component.NewID(nopType) + + traces, err := factory.CreateTracesExporter(context.Background(), set, cfg) + require.NoError(t, err) + bTraces, err := builder.CreateTraces(context.Background(), set) + require.NoError(t, err) + assert.IsType(t, traces, bTraces) + + metrics, err := factory.CreateMetricsExporter(context.Background(), set, cfg) + require.NoError(t, err) + bMetrics, err := builder.CreateMetrics(context.Background(), set) + require.NoError(t, err) + assert.IsType(t, metrics, bMetrics) + + logs, err := factory.CreateLogsExporter(context.Background(), set, cfg) + require.NoError(t, err) + bLogs, err := builder.CreateLogs(context.Background(), set) + require.NoError(t, err) + assert.IsType(t, logs, bLogs) +}