Skip to content

Commit

Permalink
bring back nop builder and deprecate it
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Aug 19, 2024
1 parent 7ea8a3a commit a91060a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions exporter/exportertest/nop_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
28 changes: 28 additions & 0 deletions exporter/exportertest/nop_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit a91060a

Please sign in to comment.