Skip to content

Commit e603bd8

Browse files
Standarize Settings instead of Params and Parameters
Fixes #2650 Changes: Replace: ReceiverCreateParams, ProcessorCreateParams, ExtensionCreateParams and ExporterCreateParams with ComponentSettings struct Replace all dependencies in Extensions, Exporters, Processors and Receivers Replace Parameters and settings structs with new struct Settings Replace dependencies in service and main Update tests Signed-off-by: Patryk Matyjasek <[email protected]> # Conflicts: # exporter/kafkaexporter/factory.go # exporter/kafkaexporter/factory_test.go # exporter/kafkaexporter/kafka_exporter.go # exporter/kafkaexporter/kafka_exporter_test.go # exporter/prometheusexporter/factory.go # receiver/jaegerreceiver/jaeger_agent_test.go # receiver/jaegerreceiver/trace_receiver_test.go # receiver/kafkareceiver/factory.go # receiver/kafkareceiver/factory_test.go # receiver/kafkareceiver/kafka_receiver.go # receiver/kafkareceiver/kafka_receiver_test.go # Conflicts: # processor/batchprocessor/batch_processor.go # processor/batchprocessor/batch_processor_test.go # processor/batchprocessor/factory.go # processor/filterprocessor/filter_processor_test.go # service/application.go
1 parent 983114f commit e603bd8

File tree

131 files changed

+698
-703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+698
-703
lines changed

cmd/otelcol/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ func main() {
3737
Version: version.Version,
3838
}
3939

40-
if err := run(service.Parameters{ApplicationStartInfo: info, Factories: factories}); err != nil {
40+
componentSettings := component.ComponentSettings{
41+
ApplicationStartInfo: info,
42+
}
43+
44+
if err := run(service.Settings{ComponentSettings: componentSettings, Factories: factories}); err != nil {
4145
log.Fatal(err)
4246
}
4347
}
4448

45-
func runInteractive(params service.Parameters) error {
49+
func runInteractive(params service.Settings) error {
4650
app, err := service.New(params)
4751
if err != nil {
4852
return fmt.Errorf("failed to construct the application: %w", err)

cmd/otelcol/main_others.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ package main
1818

1919
import "go.opentelemetry.io/collector/service"
2020

21-
func run(params service.Parameters) error {
21+
func run(params service.Settings) error {
2222
return runInteractive(params)
2323
}

component/component.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919

2020
"go.opentelemetry.io/collector/config"
21+
"go.uber.org/zap"
2122
)
2223

2324
// Component is either a receiver, exporter, processor or extension.
@@ -60,6 +61,16 @@ type Component interface {
6061
Shutdown(ctx context.Context) error
6162
}
6263

64+
// ComponentSettings is passed to ReceiverFactory.Create* functions.
65+
type ComponentSettings struct {
66+
// Logger that the factory can use during creation and can pass to the created
67+
// component to be used later as well.
68+
Logger *zap.Logger
69+
70+
// ApplicationStartInfo can be used by components for informational purposes
71+
ApplicationStartInfo ApplicationStartInfo
72+
}
73+
6374
// Kind specified one of the 4 components kinds, see consts below.
6475
type Kind int
6576

component/componenttest/nop_exporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (f *nopExporterFactory) CreateDefaultConfig() config.Exporter {
4848
// CreateTracesExporter implements component.ExporterFactory interface.
4949
func (f *nopExporterFactory) CreateTracesExporter(
5050
_ context.Context,
51-
_ component.ExporterCreateParams,
51+
_ component.ComponentSettings,
5252
_ config.Exporter,
5353
) (component.TracesExporter, error) {
5454
return nopExporterInstance, nil
@@ -57,7 +57,7 @@ func (f *nopExporterFactory) CreateTracesExporter(
5757
// CreateMetricsExporter implements component.ExporterFactory interface.
5858
func (f *nopExporterFactory) CreateMetricsExporter(
5959
_ context.Context,
60-
_ component.ExporterCreateParams,
60+
_ component.ComponentSettings,
6161
_ config.Exporter,
6262
) (component.MetricsExporter, error) {
6363
return nopExporterInstance, nil
@@ -66,7 +66,7 @@ func (f *nopExporterFactory) CreateMetricsExporter(
6666
// CreateLogsExporter implements component.ExporterFactory interface.
6767
func (f *nopExporterFactory) CreateLogsExporter(
6868
_ context.Context,
69-
_ component.ExporterCreateParams,
69+
_ component.ComponentSettings,
7070
_ config.Exporter,
7171
) (component.LogsExporter, error) {
7272
return nopExporterInstance, nil

component/componenttest/nop_exporter_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ func TestNewNopExporterFactory(t *testing.T) {
3333
cfg := factory.CreateDefaultConfig()
3434
assert.Equal(t, &config.ExporterSettings{TypeVal: factory.Type()}, cfg)
3535

36-
traces, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{}, cfg)
36+
traces, err := factory.CreateTracesExporter(context.Background(), component.ComponentSettings{}, cfg)
3737
require.NoError(t, err)
3838
assert.NoError(t, traces.Start(context.Background(), NewNopHost()))
3939
assert.NoError(t, traces.ConsumeTraces(context.Background(), pdata.NewTraces()))
4040
assert.NoError(t, traces.Shutdown(context.Background()))
4141

42-
metrics, err := factory.CreateMetricsExporter(context.Background(), component.ExporterCreateParams{}, cfg)
42+
metrics, err := factory.CreateMetricsExporter(context.Background(), component.ComponentSettings{}, cfg)
4343
require.NoError(t, err)
4444
assert.NoError(t, metrics.Start(context.Background(), NewNopHost()))
4545
assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pdata.NewMetrics()))
4646
assert.NoError(t, metrics.Shutdown(context.Background()))
4747

48-
logs, err := factory.CreateLogsExporter(context.Background(), component.ExporterCreateParams{}, cfg)
48+
logs, err := factory.CreateLogsExporter(context.Background(), component.ComponentSettings{}, cfg)
4949
require.NoError(t, err)
5050
assert.NoError(t, logs.Start(context.Background(), NewNopHost()))
5151
assert.NoError(t, logs.ConsumeLogs(context.Background(), pdata.NewLogs()))

component/componenttest/nop_extension.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (f *nopExtensionFactory) CreateDefaultConfig() config.Extension {
4747
// CreateExtension implements component.ExtensionFactory interface.
4848
func (f *nopExtensionFactory) CreateExtension(
4949
_ context.Context,
50-
_ component.ExtensionCreateParams,
50+
_ component.ComponentSettings,
5151
_ config.Extension,
5252
) (component.Extension, error) {
5353
return nopExtensionInstance, nil

component/componenttest/nop_extension_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestNewNopExtensionFactory(t *testing.T) {
3232
cfg := factory.CreateDefaultConfig()
3333
assert.Equal(t, &config.ExtensionSettings{TypeVal: factory.Type()}, cfg)
3434

35-
traces, err := factory.CreateExtension(context.Background(), component.ExtensionCreateParams{}, cfg)
35+
traces, err := factory.CreateExtension(context.Background(), component.ComponentSettings{}, cfg)
3636
require.NoError(t, err)
3737
assert.NoError(t, traces.Start(context.Background(), NewNopHost()))
3838
assert.NoError(t, traces.Shutdown(context.Background()))

component/componenttest/nop_processor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (f *nopProcessorFactory) CreateDefaultConfig() config.Processor {
5151
// CreateTracesProcessor implements component.ProcessorFactory interface.
5252
func (f *nopProcessorFactory) CreateTracesProcessor(
5353
_ context.Context,
54-
_ component.ProcessorCreateParams,
54+
_ component.ComponentSettings,
5555
_ config.Processor,
5656
_ consumer.Traces,
5757
) (component.TracesProcessor, error) {
@@ -61,7 +61,7 @@ func (f *nopProcessorFactory) CreateTracesProcessor(
6161
// CreateMetricsProcessor implements component.ProcessorFactory interface.
6262
func (f *nopProcessorFactory) CreateMetricsProcessor(
6363
_ context.Context,
64-
_ component.ProcessorCreateParams,
64+
_ component.ComponentSettings,
6565
_ config.Processor,
6666
_ consumer.Metrics,
6767
) (component.MetricsProcessor, error) {
@@ -71,7 +71,7 @@ func (f *nopProcessorFactory) CreateMetricsProcessor(
7171
// CreateLogsProcessor implements component.ProcessorFactory interface.
7272
func (f *nopProcessorFactory) CreateLogsProcessor(
7373
_ context.Context,
74-
_ component.ProcessorCreateParams,
74+
_ component.ComponentSettings,
7575
_ config.Processor,
7676
_ consumer.Logs,
7777
) (component.LogsProcessor, error) {

component/componenttest/nop_processor_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ func TestNewNopProcessorFactory(t *testing.T) {
3434
cfg := factory.CreateDefaultConfig()
3535
assert.Equal(t, &config.ProcessorSettings{TypeVal: factory.Type()}, cfg)
3636

37-
traces, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop())
37+
traces, err := factory.CreateTracesProcessor(context.Background(), component.ComponentSettings{}, cfg, consumertest.NewNop())
3838
require.NoError(t, err)
3939
assert.Equal(t, component.ProcessorCapabilities{MutatesConsumedData: false}, traces.GetCapabilities())
4040
assert.NoError(t, traces.Start(context.Background(), NewNopHost()))
4141
assert.NoError(t, traces.ConsumeTraces(context.Background(), pdata.NewTraces()))
4242
assert.NoError(t, traces.Shutdown(context.Background()))
4343

44-
metrics, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop())
44+
metrics, err := factory.CreateMetricsProcessor(context.Background(), component.ComponentSettings{}, cfg, consumertest.NewNop())
4545
require.NoError(t, err)
4646
assert.Equal(t, component.ProcessorCapabilities{MutatesConsumedData: false}, metrics.GetCapabilities())
4747
assert.NoError(t, metrics.Start(context.Background(), NewNopHost()))
4848
assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pdata.NewMetrics()))
4949
assert.NoError(t, metrics.Shutdown(context.Background()))
5050

51-
logs, err := factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewNop())
51+
logs, err := factory.CreateLogsProcessor(context.Background(), component.ComponentSettings{}, cfg, consumertest.NewNop())
5252
require.NoError(t, err)
5353
assert.Equal(t, component.ProcessorCapabilities{MutatesConsumedData: false}, logs.GetCapabilities())
5454
assert.NoError(t, logs.Start(context.Background(), NewNopHost()))

component/componenttest/nop_receiver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (f *nopReceiverFactory) CreateDefaultConfig() config.Receiver {
4848
// CreateTracesReceiver implements component.ReceiverFactory interface.
4949
func (f *nopReceiverFactory) CreateTracesReceiver(
5050
_ context.Context,
51-
_ component.ReceiverCreateParams,
51+
_ component.ComponentSettings,
5252
_ config.Receiver,
5353
_ consumer.Traces,
5454
) (component.TracesReceiver, error) {
@@ -58,7 +58,7 @@ func (f *nopReceiverFactory) CreateTracesReceiver(
5858
// CreateMetricsReceiver implements component.ReceiverFactory interface.
5959
func (f *nopReceiverFactory) CreateMetricsReceiver(
6060
_ context.Context,
61-
_ component.ReceiverCreateParams,
61+
_ component.ComponentSettings,
6262
_ config.Receiver,
6363
_ consumer.Metrics,
6464
) (component.MetricsReceiver, error) {
@@ -68,7 +68,7 @@ func (f *nopReceiverFactory) CreateMetricsReceiver(
6868
// CreateLogsReceiver implements component.ReceiverFactory interface.
6969
func (f *nopReceiverFactory) CreateLogsReceiver(
7070
_ context.Context,
71-
_ component.ReceiverCreateParams,
71+
_ component.ComponentSettings,
7272
_ config.Receiver,
7373
_ consumer.Logs,
7474
) (component.LogsReceiver, error) {

0 commit comments

Comments
 (0)