Skip to content

Commit f38e293

Browse files
authored
Use Factory instead of ProcessorFactory when package contains processor (#131)
* Use Factory instead of ReceiverFactory when package contains receiver * Change the name of the test factory in processor
1 parent c8f3572 commit f38e293

File tree

14 files changed

+46
-46
lines changed

14 files changed

+46
-46
lines changed

cmd/occollector/app/builder/pipelines_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (pb *PipelinesBuilder) buildPipeline(
9696
procName := pipelineCfg.Processors[i]
9797
procCfg := pb.config.Processors[procName]
9898

99-
factory := processor.GetProcessorFactory(procCfg.Type())
99+
factory := processor.GetFactory(procCfg.Type())
100100

101101
// This processor must point to the next consumer and then
102102
// it becomes the next for the previous one (previous in the pipeline,

configv2/configv2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func loadProcessors(v *viper.Viper) (models.Processors, error) {
306306
}
307307

308308
// Find processor factory based on "type" that we read from config source.
309-
factory := processor.GetProcessorFactory(typeStr)
309+
factory := processor.GetFactory(typeStr)
310310
if factory == nil {
311311
return nil, &configError{
312312
code: errUnknownProcessorType,

configv2/example_factories.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,6 @@ func RegisterTestFactories() error {
330330
_ = receiver.RegisterFactory(&ExampleReceiverFactory{})
331331
_ = receiver.RegisterFactory(&MultiProtoReceiverFactory{})
332332
_ = exporter.RegisterFactory(&ExampleExporterFactory{})
333-
_ = processor.RegisterProcessorFactory(&ExampleProcessorFactory{})
333+
_ = processor.RegisterFactory(&ExampleProcessorFactory{})
334334
return nil
335335
}

internal/collector/processor/nodebatcher/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var _ = configv2.RegisterTestFactories()
3131

3232
func TestLoadConfig(t *testing.T) {
3333

34-
factory := processor.GetProcessorFactory(typeStr)
34+
factory := processor.GetFactory(typeStr)
3535

3636
config, err := configv2.LoadConfigFile(t, path.Join(".", "testdata", "config.yaml"))
3737

internal/collector/processor/nodebatcher/factory.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ import (
2323
"github.com/open-telemetry/opentelemetry-service/processor"
2424
)
2525

26-
var _ = processor.RegisterProcessorFactory(&processorFactory{})
26+
var _ = processor.RegisterFactory(&factory{})
2727

2828
const (
2929
// The value of "type" key in configuration.
3030
typeStr = "batch"
3131
)
3232

33-
// processorFactory is the factory for batch processor.
34-
type processorFactory struct {
33+
// factory is the factory for batch processor.
34+
type factory struct {
3535
}
3636

3737
// Type gets the type of the config created by this factory.
38-
func (f *processorFactory) Type() string {
38+
func (f *factory) Type() string {
3939
return typeStr
4040
}
4141

4242
// CreateDefaultConfig creates the default configuration for processor.
43-
func (f *processorFactory) CreateDefaultConfig() models.Processor {
43+
func (f *factory) CreateDefaultConfig() models.Processor {
4444
removeAfterTicks := int(defaultRemoveAfterCycles)
4545
sendBatchSize := int(defaultSendBatchSize)
4646
tickTime := defaultTickTime
@@ -60,7 +60,7 @@ func (f *processorFactory) CreateDefaultConfig() models.Processor {
6060
}
6161

6262
// CreateTraceProcessor creates a trace processor based on this config.
63-
func (f *processorFactory) CreateTraceProcessor(
63+
func (f *factory) CreateTraceProcessor(
6464
logger *zap.Logger,
6565
nextConsumer consumer.TraceConsumer,
6666
c models.Processor,
@@ -96,7 +96,7 @@ func (f *processorFactory) CreateTraceProcessor(
9696
}
9797

9898
// CreateMetricsProcessor creates a metrics processor based on this config.
99-
func (f *processorFactory) CreateMetricsProcessor(
99+
func (f *factory) CreateMetricsProcessor(
100100
logger *zap.Logger,
101101
nextConsumer consumer.MetricsConsumer,
102102
cfg models.Processor,

internal/collector/processor/nodebatcher/factory_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ import (
2626
)
2727

2828
func TestCreateDefaultConfig(t *testing.T) {
29-
factory := processor.GetProcessorFactory(typeStr)
29+
factory := processor.GetFactory(typeStr)
3030
require.NotNil(t, factory)
3131

3232
cfg := factory.CreateDefaultConfig()
3333
assert.NotNil(t, cfg, "failed to create default config")
3434
}
3535

3636
func TestCreateProcessor(t *testing.T) {
37-
factory := processor.GetProcessorFactory(typeStr)
37+
factory := processor.GetFactory(typeStr)
3838
require.NotNil(t, factory)
3939

4040
cfg := factory.CreateDefaultConfig()

internal/collector/processor/queued/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var _ = configv2.RegisterTestFactories()
3131

3232
func TestLoadConfig(t *testing.T) {
3333

34-
factory := processor.GetProcessorFactory(typeStr)
34+
factory := processor.GetFactory(typeStr)
3535

3636
config, err := configv2.LoadConfigFile(t, path.Join(".", "testdata", "config.yaml"))
3737

internal/collector/processor/queued/factory.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ import (
2424
"go.uber.org/zap"
2525
)
2626

27-
var _ = processor.RegisterProcessorFactory(&processorFactory{})
27+
var _ = processor.RegisterFactory(&factory{})
2828

2929
const (
3030
// The value of "type" key in configuration.
3131
typeStr = "queued-retry"
3232
)
3333

34-
// processorFactory is the factory for OpenCensus exporter.
35-
type processorFactory struct {
34+
// factory is the factory for OpenCensus exporter.
35+
type factory struct {
3636
}
3737

3838
// Type gets the type of the Option config created by this factory.
39-
func (f *processorFactory) Type() string {
39+
func (f *factory) Type() string {
4040
return typeStr
4141
}
4242

4343
// CreateDefaultConfig creates the default configuration for exporter.
44-
func (f *processorFactory) CreateDefaultConfig() models.Processor {
44+
func (f *factory) CreateDefaultConfig() models.Processor {
4545
return &ConfigV2{
4646
ProcessorSettings: models.ProcessorSettings{
4747
TypeVal: typeStr,
@@ -55,7 +55,7 @@ func (f *processorFactory) CreateDefaultConfig() models.Processor {
5555
}
5656

5757
// CreateTraceProcessor creates a trace processor based on this config.
58-
func (f *processorFactory) CreateTraceProcessor(
58+
func (f *factory) CreateTraceProcessor(
5959
logger *zap.Logger,
6060
nextConsumer consumer.TraceConsumer,
6161
cfg models.Processor,
@@ -70,7 +70,7 @@ func (f *processorFactory) CreateTraceProcessor(
7070
}
7171

7272
// CreateMetricsProcessor creates a metrics processor based on this config.
73-
func (f *processorFactory) CreateMetricsProcessor(
73+
func (f *factory) CreateMetricsProcessor(
7474
logger *zap.Logger,
7575
nextConsumer consumer.MetricsConsumer,
7676
cfg models.Processor,

internal/collector/processor/queued/factory_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ import (
2626
)
2727

2828
func TestCreateDefaultConfig(t *testing.T) {
29-
factory := processor.GetProcessorFactory(typeStr)
29+
factory := processor.GetFactory(typeStr)
3030
require.NotNil(t, factory)
3131

3232
cfg := factory.CreateDefaultConfig()
3333
assert.NotNil(t, cfg, "failed to create default config")
3434
}
3535

3636
func TestCreateProcessor(t *testing.T) {
37-
factory := processor.GetProcessorFactory(typeStr)
37+
factory := processor.GetFactory(typeStr)
3838
require.NotNil(t, factory)
3939

4040
cfg := factory.CreateDefaultConfig()

processor/addattributesprocessor/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var _ = configv2.RegisterTestFactories()
3030

3131
func TestLoadConfig(t *testing.T) {
3232

33-
factory := processor.GetProcessorFactory(typeStr)
33+
factory := processor.GetFactory(typeStr)
3434

3535
config, err := configv2.LoadConfigFile(t, path.Join(".", "testdata", "config.yaml"))
3636

0 commit comments

Comments
 (0)