Skip to content

Commit

Permalink
Rename to TracesNop
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Oct 19, 2020
1 parent e42d0bc commit bc5956d
Show file tree
Hide file tree
Showing 26 changed files with 101 additions and 101 deletions.
12 changes: 6 additions & 6 deletions consumer/consumertest/nop.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ func (nc *nopConsumer) ConsumeLogs(context.Context, pdata.Logs) error {
return nil
}

// NewNopTraces creates an TraceConsumer that just drops the received data.
func NewNopTraces() consumer.TraceConsumer {
// NewTracesNop creates an TraceConsumer that just drops the received data.
func NewTracesNop() consumer.TraceConsumer {
return nopInstance
}

// NewNopMetrics creates an MetricsConsumer that just drops the received data.
func NewNopMetrics() consumer.MetricsConsumer {
// NewMetricsNop creates an MetricsConsumer that just drops the received data.
func NewMetricsNop() consumer.MetricsConsumer {
return nopInstance
}

// NewNopLogs creates an LogsConsumer that just drops the received data.
func NewNopLogs() consumer.LogsConsumer {
// NewLogsNop creates an LogsConsumer that just drops the received data.
func NewLogsNop() consumer.LogsConsumer {
return nopInstance
}
6 changes: 3 additions & 3 deletions consumer/consumertest/nop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ import (
)

func TestNewNopTraces(t *testing.T) {
nt := NewNopTraces()
nt := NewTracesNop()
require.NotNil(t, nt)
require.NoError(t, nt.ConsumeTraces(context.Background(), pdata.NewTraces()))
}

func TestNewNopMetrics(t *testing.T) {
nm := NewNopMetrics()
nm := NewMetricsNop()
require.NotNil(t, nm)
require.NoError(t, nm.ConsumeMetrics(context.Background(), pdata.NewMetrics()))
}

func TestNopLogsConsumer(t *testing.T) {
nl := NewNopLogs()
nl := NewLogsNop()
require.NotNil(t, nl)
require.NoError(t, nl.ConsumeLogs(context.Background(), pdata.NewLogs()))
}
12 changes: 6 additions & 6 deletions processor/attributesprocessor/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestSpanProcessor_NilEmptyData(t *testing.T) {
{Key: "attribute1", Action: processorhelper.DELETE},
}

tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewNopTraces())
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, oCfg, consumertest.NewTracesNop())
require.Nil(t, err)
require.NotNil(t, tp)
for i := range testCases {
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestAttributes_FilterSpans(t *testing.T) {
},
Config: *createConfig(filterset.Strict),
}
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
require.Nil(t, err)
require.NotNil(t, tp)

Expand Down Expand Up @@ -278,7 +278,7 @@ func TestAttributes_FilterSpansByNameStrict(t *testing.T) {
SpanNames: []string{"dont_apply"},
Config: *createConfig(filterset.Strict),
}
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
require.Nil(t, err)
require.NotNil(t, tp)

Expand Down Expand Up @@ -346,7 +346,7 @@ func TestAttributes_FilterSpansByNameRegexp(t *testing.T) {
SpanNames: []string{".*dont_apply$"},
Config: *createConfig(filterset.Regexp),
}
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
require.Nil(t, err)
require.NotNil(t, tp)

Expand Down Expand Up @@ -405,7 +405,7 @@ func TestAttributes_Hash(t *testing.T) {
{Key: "user.authenticated", Action: processorhelper.HASH},
}

tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
require.Nil(t, err)
require.NotNil(t, tp)

Expand Down Expand Up @@ -449,7 +449,7 @@ func BenchmarkAttributes_FilterSpansByName(b *testing.B) {
oCfg.Include = &filterconfig.MatchProperties{
SpanNames: []string{"^apply.*"},
}
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
require.Nil(b, err)
require.NotNil(b, tp)

Expand Down
8 changes: 4 additions & 4 deletions processor/attributesprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestFactory_CreateDefaultConfig(t *testing.T) {
func TestFactoryCreateTraceProcessor_EmptyActions(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
ap, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
ap, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
assert.Error(t, err)
assert.Nil(t, ap)
}
Expand All @@ -62,7 +62,7 @@ func TestFactoryCreateTraceProcessor_InvalidActions(t *testing.T) {
oCfg.Actions = []processorhelper.ActionKeyValue{
{Key: "", Value: 123, Action: processorhelper.UPSERT},
}
ap, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
ap, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
assert.Error(t, err)
assert.Nil(t, ap)
}
Expand All @@ -75,7 +75,7 @@ func TestFactoryCreateTraceProcessor(t *testing.T) {
{Key: "a key", Action: processorhelper.DELETE},
}

tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
assert.NotNil(t, tp)
assert.NoError(t, err)

Expand All @@ -86,7 +86,7 @@ func TestFactoryCreateTraceProcessor(t *testing.T) {
oCfg.Actions = []processorhelper.ActionKeyValue{
{Action: processorhelper.DELETE},
}
tp, err = factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
tp, err = factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
assert.Nil(t, tp)
assert.Error(t, err)
}
Expand Down
6 changes: 3 additions & 3 deletions processor/cloningfanoutconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

func TestTraceProcessorCloningNotMultiplexing(t *testing.T) {
nop := consumertest.NewNopTraces()
nop := consumertest.NewTracesNop()
tfc := NewTracesCloningFanOutConnector([]consumer.TraceConsumer{nop})
assert.Same(t, nop, tfc)
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestTraceProcessorCloningMultiplexing(t *testing.T) {
}

func TestMetricsProcessorCloningNotMultiplexing(t *testing.T) {
nop := consumertest.NewNopMetrics()
nop := consumertest.NewMetricsNop()
mfc := NewMetricsFanOutConnector([]consumer.MetricsConsumer{nop})
assert.Same(t, nop, mfc)
}
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestMetricsProcessorCloningMultiplexing(t *testing.T) {
}

func TestLogsProcessorCloningNotMultiplexing(t *testing.T) {
nop := consumertest.NewNopLogs()
nop := consumertest.NewLogsNop()
lfc := NewLogsCloningFanOutConnector([]consumer.LogsConsumer{nop})
assert.Same(t, nop, lfc)
}
Expand Down
6 changes: 3 additions & 3 deletions processor/fanoutconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

func TestTracesProcessorNotMultiplexing(t *testing.T) {
nop := consumertest.NewNopTraces()
nop := consumertest.NewTracesNop()
tfc := NewTracesFanOutConnector([]consumer.TraceConsumer{nop})
assert.Same(t, nop, tfc)
}
Expand Down Expand Up @@ -87,7 +87,7 @@ func TestTraceProcessorWhenOneErrors(t *testing.T) {
}

func TestMetricsProcessorNotMultiplexing(t *testing.T) {
nop := consumertest.NewNopMetrics()
nop := consumertest.NewMetricsNop()
mfc := NewMetricsFanOutConnector([]consumer.MetricsConsumer{nop})
assert.Same(t, nop, mfc)
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestMetricsProcessorWhenOneErrors(t *testing.T) {
}

func TestLogsProcessorNotMultiplexing(t *testing.T) {
nop := consumertest.NewNopLogs()
nop := consumertest.NewLogsNop()
lfc := NewLogsFanOutConnector([]consumer.LogsConsumer{nop})
assert.Same(t, nop, lfc)
}
Expand Down
4 changes: 2 additions & 2 deletions processor/filterprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ func TestCreateProcessors(t *testing.T) {
t.Run(fmt.Sprintf("%s/%s", test.configName, name), func(t *testing.T) {
factory := NewFactory()

tp, tErr := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNopTraces())
tp, tErr := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewTracesNop())
// Not implemented error
assert.NotNil(t, tErr)
assert.Nil(t, tp)

mp, mErr := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNopMetrics())
mp, mErr := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewMetricsNop())
assert.Equal(t, test.succeed, mp != nil)
assert.Equal(t, test.succeed, mErr == nil)
})
Expand Down
12 changes: 6 additions & 6 deletions processor/memorylimiter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNopTraces())
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewTracesNop())
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.NewNopMetrics())
mp, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewMetricsNop())
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.NewNopLogs())
lp, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewLogsNop())
assert.Nil(t, lp)
assert.Error(t, err, "created processor with invalid settings")

Expand All @@ -63,17 +63,17 @@ func TestCreateProcessor(t *testing.T) {
pCfg.BallastSizeMiB = 2048
pCfg.CheckInterval = 100 * time.Millisecond

tp, err = factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewNopTraces())
tp, err = factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewTracesNop())
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.NewNopMetrics())
mp, err = factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewMetricsNop())
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.NewNopLogs())
lp, err = factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, consumertest.NewLogsNop())
assert.NoError(t, err)
assert.NotNil(t, lp)
assert.NoError(t, lp.Shutdown(context.Background()))
Expand Down
6 changes: 3 additions & 3 deletions processor/memorylimiter/memorylimiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestMetricsMemoryPressureResponse(t *testing.T) {
NameVal: typeStr,
},
},
consumertest.NewNopMetrics(),
consumertest.NewMetricsNop(),
ml,
processorhelper.WithCapabilities(processorCapabilities),
processorhelper.WithShutdown(ml.shutdown))
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestTraceMemoryPressureResponse(t *testing.T) {
NameVal: typeStr,
},
},
consumertest.NewNopTraces(),
consumertest.NewTracesNop(),
ml,
processorhelper.WithCapabilities(processorCapabilities),
processorhelper.WithShutdown(ml.shutdown))
Expand Down Expand Up @@ -255,7 +255,7 @@ func TestLogMemoryPressureResponse(t *testing.T) {
NameVal: typeStr,
},
},
consumertest.NewNopLogs(),
consumertest.NewLogsNop(),
ml,
processorhelper.WithCapabilities(processorCapabilities),
processorhelper.WithShutdown(ml.shutdown))
Expand Down
20 changes: 10 additions & 10 deletions processor/processorhelper/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestWithCapabilities(t *testing.T) {
}

func TestNewTraceExporter(t *testing.T) {
me, err := NewTraceProcessor(testCfg, consumertest.NewNopTraces(), newTestTProcessor(nil))
me, err := NewTraceProcessor(testCfg, consumertest.NewTracesNop(), newTestTProcessor(nil))
require.NoError(t, err)

assert.NoError(t, me.Start(context.Background(), componenttest.NewNopHost()))
Expand All @@ -90,7 +90,7 @@ func TestNewTraceExporter(t *testing.T) {
}

func TestNewTraceExporter_NilRequiredFields(t *testing.T) {
_, err := NewTraceProcessor(testCfg, consumertest.NewNopTraces(), nil)
_, err := NewTraceProcessor(testCfg, consumertest.NewTracesNop(), nil)
assert.Error(t, err)

_, err = NewTraceProcessor(testCfg, nil, newTestTProcessor(nil))
Expand All @@ -99,13 +99,13 @@ func TestNewTraceExporter_NilRequiredFields(t *testing.T) {

func TestNewTraceExporter_ProcessTraceError(t *testing.T) {
want := errors.New("my_error")
me, err := NewTraceProcessor(testCfg, consumertest.NewNopTraces(), newTestTProcessor(want))
me, err := NewTraceProcessor(testCfg, consumertest.NewTracesNop(), 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.NewNopMetrics(), newTestMProcessor(nil))
me, err := NewMetricsProcessor(testCfg, consumertest.NewMetricsNop(), newTestMProcessor(nil))
require.NoError(t, err)

assert.NoError(t, me.Start(context.Background(), componenttest.NewNopHost()))
Expand All @@ -114,7 +114,7 @@ func TestNewMetricsExporter(t *testing.T) {
}

func TestNewMetricsExporter_NilRequiredFields(t *testing.T) {
_, err := NewMetricsProcessor(testCfg, consumertest.NewNopMetrics(), nil)
_, err := NewMetricsProcessor(testCfg, consumertest.NewMetricsNop(), nil)
assert.Error(t, err)

_, err = NewMetricsProcessor(testCfg, nil, newTestMProcessor(nil))
Expand All @@ -123,19 +123,19 @@ func TestNewMetricsExporter_NilRequiredFields(t *testing.T) {

func TestNewMetricsExporter_ProcessMetricsError(t *testing.T) {
want := errors.New("my_error")
me, err := NewMetricsProcessor(testCfg, consumertest.NewNopMetrics(), newTestMProcessor(want))
me, err := NewMetricsProcessor(testCfg, consumertest.NewMetricsNop(), 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.NewNopMetrics(), newTestMProcessor(ErrSkipProcessingData))
me, err := NewMetricsProcessor(testCfg, consumertest.NewMetricsNop(), 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.NewNopLogs(), newTestLProcessor(nil))
me, err := NewLogsProcessor(testCfg, consumertest.NewLogsNop(), newTestLProcessor(nil))
require.NoError(t, err)

assert.NoError(t, me.Start(context.Background(), componenttest.NewNopHost()))
Expand All @@ -144,7 +144,7 @@ func TestNewLogsExporter(t *testing.T) {
}

func TestNewLogsExporter_NilRequiredFields(t *testing.T) {
_, err := NewLogsProcessor(testCfg, consumertest.NewNopLogs(), nil)
_, err := NewLogsProcessor(testCfg, consumertest.NewLogsNop(), nil)
assert.Error(t, err)

_, err = NewLogsProcessor(testCfg, nil, newTestLProcessor(nil))
Expand All @@ -153,7 +153,7 @@ func TestNewLogsExporter_NilRequiredFields(t *testing.T) {

func TestNewLogsExporter_ProcessLogError(t *testing.T) {
want := errors.New("my_error")
me, err := NewLogsProcessor(testCfg, consumertest.NewNopLogs(), newTestLProcessor(want))
me, err := NewLogsProcessor(testCfg, consumertest.NewLogsNop(), newTestLProcessor(want))
require.NoError(t, err)
assert.Equal(t, want, me.ConsumeLogs(context.Background(), testdata.GenerateLogDataEmpty()))
}
Expand Down
8 changes: 4 additions & 4 deletions processor/resourceprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func TestCreateProcessor(t *testing.T) {
},
}

tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
tp, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
assert.NoError(t, err)
assert.NotNil(t, tp)

mp, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopMetrics())
mp, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewMetricsNop())
assert.NoError(t, err)
assert.NotNil(t, mp)
}
Expand All @@ -60,10 +60,10 @@ func TestInvalidEmptyActions(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

_, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopTraces())
_, err := factory.CreateTraceProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
assert.Error(t, err)

_, err = factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNopMetrics())
_, err = factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewMetricsNop())
assert.Error(t, err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.NewNopTraces())
tp, err := createTraceProcessor(context.Background(), params, cfg, consumertest.NewTracesNop())
assert.NotNil(t, tp)
assert.NoError(t, err, "cannot create trace processor")
}
Loading

0 comments on commit bc5956d

Please sign in to comment.