From 3fc208d38224f99c20897066ed42477908b5f965 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Wed, 23 Nov 2022 11:00:45 -0800 Subject: [PATCH] Deprecate special Configs for each component type, use a standard opaque Config Signed-off-by: Bogdan Drutu --- .chloggen/rmconfig.yaml | 11 ++++ component/component.go | 20 ++++++- component/componenttest/nop_exporter.go | 8 +-- component/componenttest/nop_extension.go | 4 +- component/componenttest/nop_processor.go | 8 +-- component/componenttest/nop_receiver.go | 8 +-- component/componenttest/shutdown_verifier.go | 4 +- component/config.go | 8 --- component/exporter.go | 57 +++++++------------ component/exporter_test.go | 10 ++-- component/extension.go | 50 +++++----------- component/extension_test.go | 4 +- component/processor.go | 57 +++++++------------ component/processor_test.go | 10 ++-- component/receiver.go | 57 +++++++------------ component/receiver_test.go | 10 ++-- config/exporter.go | 2 +- config/extension.go | 2 +- config/processor.go | 2 +- config/receiver.go | 2 +- connector/connector.go | 15 ++--- exporter/exporterhelper/common.go | 2 +- exporter/exporterhelper/logs.go | 2 +- exporter/exporterhelper/metrics.go | 2 +- exporter/exporterhelper/traces.go | 2 +- exporter/loggingexporter/config.go | 2 +- exporter/loggingexporter/factory.go | 8 +-- exporter/otlpexporter/config.go | 2 +- exporter/otlpexporter/factory.go | 8 +-- exporter/otlpexporter/otlp.go | 2 +- exporter/otlphttpexporter/config.go | 2 +- exporter/otlphttpexporter/factory.go | 8 +-- exporter/otlphttpexporter/otlp.go | 2 +- exporter/otlphttpexporter/otlp_test.go | 4 +- extension/ballastextension/factory.go | 4 +- extension/zpagesextension/config.go | 2 +- extension/zpagesextension/factory.go | 4 +- processor/batchprocessor/config.go | 2 +- processor/batchprocessor/factory.go | 8 +-- processor/memorylimiterprocessor/config.go | 2 +- processor/memorylimiterprocessor/factory.go | 14 ++--- processor/processorhelper/logs.go | 2 +- processor/processorhelper/metrics.go | 2 +- processor/processorhelper/traces.go | 2 +- receiver/otlpreceiver/config.go | 2 +- receiver/otlpreceiver/factory.go | 8 +-- service/config.go | 8 +-- service/config_provider_test.go | 8 +-- service/config_test.go | 8 +-- service/extensions/extensions.go | 4 +- service/extensions/extensions_test.go | 16 +++--- .../internal/configunmarshaler/exporters.go | 6 +- .../configunmarshaler/exporters_test.go | 2 +- .../internal/configunmarshaler/extensions.go | 6 +- .../configunmarshaler/extensions_test.go | 2 +- .../internal/configunmarshaler/processors.go | 6 +- .../configunmarshaler/processors_test.go | 2 +- .../internal/configunmarshaler/receivers.go | 6 +- .../configunmarshaler/receivers_test.go | 2 +- service/internal/pipelines/pipelines.go | 24 ++++---- service/internal/pipelines/pipelines_test.go | 36 ++++++------ .../testcomponents/example_exporter.go | 8 +-- .../testcomponents/example_processor.go | 8 +-- .../testcomponents/example_receiver.go | 12 ++-- 64 files changed, 276 insertions(+), 335 deletions(-) create mode 100755 .chloggen/rmconfig.yaml diff --git a/.chloggen/rmconfig.yaml b/.chloggen/rmconfig.yaml new file mode 100755 index 00000000000..2fede97bf08 --- /dev/null +++ b/.chloggen/rmconfig.yaml @@ -0,0 +1,11 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: deprecation + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: component + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Deprecate `component.[Exporter|Extension|Processor|Receiver]Config` in favor of `component.Config` + +# One or more tracking issues or pull requests related to the change +issues: [6578] diff --git a/component/component.go b/component/component.go index 5cc4de8bb84..6f507a085d1 100644 --- a/component/component.go +++ b/component/component.go @@ -161,7 +161,7 @@ func (sl StabilityLevel) LogMessage() string { return "Stability level of component is undefined" } -// Factory is implemented by all component factories. +// Factory is implemented by all Component factories. // // This interface cannot be directly implemented. Implementations must // use the factory helpers for the appropriate component type. @@ -169,11 +169,29 @@ type Factory interface { // Type gets the type of the component created by this factory. Type() Type + // CreateDefaultConfig creates the default configuration for the Component. + // This method can be called multiple times depending on the pipeline + // configuration and should not cause side-effects that prevent the creation + // of multiple instances of the Component. + // The object returned by this method needs to pass the checks implemented by + // 'componenttest.CheckConfigStruct'. It is recommended to have these checks in the + // tests of any implementation of the Factory interface. + CreateDefaultConfig() Config + unexportedFactoryFunc() } +// CreateDefaultConfigFunc is the equivalent of Factory.CreateDefaultConfig(). +type CreateDefaultConfigFunc func() Config + +// CreateDefaultConfig implements Factory.CreateDefaultConfig(). +func (f CreateDefaultConfigFunc) CreateDefaultConfig() Config { + return f() +} + type baseFactory struct { cfgType Type + CreateDefaultConfigFunc } func (baseFactory) unexportedFactoryFunc() {} diff --git a/component/componenttest/nop_exporter.go b/component/componenttest/nop_exporter.go index 2617d7c29d1..c1f54017047 100644 --- a/component/componenttest/nop_exporter.go +++ b/component/componenttest/nop_exporter.go @@ -38,7 +38,7 @@ type nopExporterConfig struct { func NewNopExporterFactory() component.ExporterFactory { return component.NewExporterFactory( "nop", - func() component.ExporterConfig { + func() component.Config { return &nopExporterConfig{ ExporterSettings: config.NewExporterSettings(component.NewID("nop")), } @@ -49,15 +49,15 @@ func NewNopExporterFactory() component.ExporterFactory { ) } -func createTracesExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.TracesExporter, error) { +func createTracesExporter(context.Context, component.ExporterCreateSettings, component.Config) (component.TracesExporter, error) { return nopExporterInstance, nil } -func createMetricsExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.MetricsExporter, error) { +func createMetricsExporter(context.Context, component.ExporterCreateSettings, component.Config) (component.MetricsExporter, error) { return nopExporterInstance, nil } -func createLogsExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.LogsExporter, error) { +func createLogsExporter(context.Context, component.ExporterCreateSettings, component.Config) (component.LogsExporter, error) { return nopExporterInstance, nil } diff --git a/component/componenttest/nop_extension.go b/component/componenttest/nop_extension.go index 8960e530012..f3dbf6bf97f 100644 --- a/component/componenttest/nop_extension.go +++ b/component/componenttest/nop_extension.go @@ -37,12 +37,12 @@ type nopExtensionConfig struct { func NewNopExtensionFactory() component.ExtensionFactory { return component.NewExtensionFactory( "nop", - func() component.ExtensionConfig { + func() component.Config { return &nopExtensionConfig{ ExtensionSettings: config.NewExtensionSettings(component.NewID("nop")), } }, - func(context.Context, component.ExtensionCreateSettings, component.ExtensionConfig) (component.Extension, error) { + func(context.Context, component.ExtensionCreateSettings, component.Config) (component.Extension, error) { return nopExtensionInstance, nil }, component.StabilityLevelStable) diff --git a/component/componenttest/nop_processor.go b/component/componenttest/nop_processor.go index 6fa0a4052b9..1ef661f00db 100644 --- a/component/componenttest/nop_processor.go +++ b/component/componenttest/nop_processor.go @@ -39,7 +39,7 @@ type nopProcessorConfig struct { func NewNopProcessorFactory() component.ProcessorFactory { return component.NewProcessorFactory( "nop", - func() component.ProcessorConfig { + func() component.Config { return &nopProcessorConfig{ ProcessorSettings: config.NewProcessorSettings(component.NewID("nop")), } @@ -50,15 +50,15 @@ func NewNopProcessorFactory() component.ProcessorFactory { ) } -func createTracesProcessor(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Traces) (component.TracesProcessor, error) { +func createTracesProcessor(context.Context, component.ProcessorCreateSettings, component.Config, consumer.Traces) (component.TracesProcessor, error) { return nopProcessorInstance, nil } -func createMetricsProcessor(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Metrics) (component.MetricsProcessor, error) { +func createMetricsProcessor(context.Context, component.ProcessorCreateSettings, component.Config, consumer.Metrics) (component.MetricsProcessor, error) { return nopProcessorInstance, nil } -func createLogsProcessor(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Logs) (component.LogsProcessor, error) { +func createLogsProcessor(context.Context, component.ProcessorCreateSettings, component.Config, consumer.Logs) (component.LogsProcessor, error) { return nopProcessorInstance, nil } diff --git a/component/componenttest/nop_receiver.go b/component/componenttest/nop_receiver.go index 8adc4b4615d..33b9f770776 100644 --- a/component/componenttest/nop_receiver.go +++ b/component/componenttest/nop_receiver.go @@ -38,7 +38,7 @@ type nopReceiverConfig struct { func NewNopReceiverFactory() component.ReceiverFactory { return component.NewReceiverFactory( "nop", - func() component.ReceiverConfig { + func() component.Config { return &nopReceiverConfig{ ReceiverSettings: config.NewReceiverSettings(component.NewID("nop")), } @@ -48,15 +48,15 @@ func NewNopReceiverFactory() component.ReceiverFactory { component.WithLogsReceiver(createLogsReceiver, component.StabilityLevelStable)) } -func createTracesReceiver(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Traces) (component.TracesReceiver, error) { +func createTracesReceiver(context.Context, component.ReceiverCreateSettings, component.Config, consumer.Traces) (component.TracesReceiver, error) { return nopReceiverInstance, nil } -func createMetricsReceiver(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Metrics) (component.MetricsReceiver, error) { +func createMetricsReceiver(context.Context, component.ReceiverCreateSettings, component.Config, consumer.Metrics) (component.MetricsReceiver, error) { return nopReceiverInstance, nil } -func createLogsReceiver(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Logs) (component.LogsReceiver, error) { +func createLogsReceiver(context.Context, component.ReceiverCreateSettings, component.Config, consumer.Logs) (component.LogsReceiver, error) { return nopReceiverInstance, nil } diff --git a/component/componenttest/shutdown_verifier.go b/component/componenttest/shutdown_verifier.go index 06a6088398c..6207fc119ed 100644 --- a/component/componenttest/shutdown_verifier.go +++ b/component/componenttest/shutdown_verifier.go @@ -27,7 +27,7 @@ import ( "go.opentelemetry.io/collector/internal/testdata" ) -func verifyTracesProcessorDoesntProduceAfterShutdown(t *testing.T, factory component.ProcessorFactory, cfg component.ProcessorConfig) { +func verifyTracesProcessorDoesntProduceAfterShutdown(t *testing.T, factory component.ProcessorFactory, cfg component.Config) { // Create a processor and output its produce to a sink. nextSink := new(consumertest.TracesSink) processor, err := factory.CreateTracesProcessor( @@ -61,7 +61,7 @@ func verifyTracesProcessorDoesntProduceAfterShutdown(t *testing.T, factory compo } // VerifyProcessorShutdown verifies the processor doesn't produce telemetry data after shutdown. -func VerifyProcessorShutdown(t *testing.T, factory component.ProcessorFactory, cfg component.ProcessorConfig) { +func VerifyProcessorShutdown(t *testing.T, factory component.ProcessorFactory, cfg component.Config) { verifyTracesProcessorDoesntProduceAfterShutdown(t, factory, cfg) // TODO: add metrics and logs verification. // TODO: add other shutdown verifications. diff --git a/component/config.go b/component/config.go index 0d7028c69b1..29c71f4bab0 100644 --- a/component/config.go +++ b/component/config.go @@ -28,14 +28,6 @@ type Config interface { privateConfig() } -// CreateDefaultConfigFunc is the equivalent of Factory.CreateDefaultConfig(). -type CreateDefaultConfigFunc func() Config - -// CreateDefaultConfig implements Factory.CreateDefaultConfig(). -func (f CreateDefaultConfigFunc) CreateDefaultConfig() Config { - return f() -} - // As interface types are only used for static typing, a common idiom to find the reflection Type // for an interface type Foo is to use a *Foo value. var configValidatorType = reflect.TypeOf((*ConfigValidator)(nil)).Elem() diff --git a/component/exporter.go b/component/exporter.go index 93610821e08..db1013d47c5 100644 --- a/component/exporter.go +++ b/component/exporter.go @@ -17,20 +17,14 @@ package component // import "go.opentelemetry.io/collector/component" import ( "context" - "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/consumer" ) -// ExporterConfig is the configuration of a component.Exporter. Specific Exporter must implement -// this interface and must embed config.ExporterSettings struct or a struct that extends it. -type ExporterConfig interface { - Config -} +// Deprecated: [v0.67.0] use Config. +type ExporterConfig = Config // Deprecated: [v0.67.0] use UnmarshalConfig. -func UnmarshalExporterConfig(conf *confmap.Conf, cfg ExporterConfig) error { - return UnmarshalConfig(conf, cfg) -} +var UnmarshalExporterConfig = UnmarshalConfig // TracesExporter is an Exporter that can consume traces. type TracesExporter interface { @@ -65,19 +59,10 @@ type ExporterCreateSettings struct { type ExporterFactory interface { Factory - // CreateDefaultConfig creates the default configuration for the Exporter. - // This method can be called multiple times depending on the pipeline - // configuration and should not cause side-effects that prevent the creation - // of multiple instances of the Exporter. - // The object returned by this method needs to pass the checks implemented by - // 'componenttest.CheckConfigStruct'. It is recommended to have these checks in the - // tests of any implementation of the Factory interface. - CreateDefaultConfig() ExporterConfig - // CreateTracesExporter creates a TracesExporter based on this config. // If the exporter type does not support tracing or if the config is not valid, // an error will be returned instead. - CreateTracesExporter(ctx context.Context, set ExporterCreateSettings, cfg ExporterConfig) (TracesExporter, error) + CreateTracesExporter(ctx context.Context, set ExporterCreateSettings, cfg Config) (TracesExporter, error) // TracesExporterStability gets the stability level of the TracesExporter. TracesExporterStability() StabilityLevel @@ -85,7 +70,7 @@ type ExporterFactory interface { // CreateMetricsExporter creates a MetricsExporter based on this config. // If the exporter type does not support metrics or if the config is not valid, // an error will be returned instead. - CreateMetricsExporter(ctx context.Context, set ExporterCreateSettings, cfg ExporterConfig) (MetricsExporter, error) + CreateMetricsExporter(ctx context.Context, set ExporterCreateSettings, cfg Config) (MetricsExporter, error) // MetricsExporterStability gets the stability level of the MetricsExporter. MetricsExporterStability() StabilityLevel @@ -93,7 +78,7 @@ type ExporterFactory interface { // CreateLogsExporter creates a LogsExporter based on the config. // If the exporter type does not support logs or if the config is not valid, // an error will be returned instead. - CreateLogsExporter(ctx context.Context, set ExporterCreateSettings, cfg ExporterConfig) (LogsExporter, error) + CreateLogsExporter(ctx context.Context, set ExporterCreateSettings, cfg Config) (LogsExporter, error) // LogsExporterStability gets the stability level of the LogsExporter. LogsExporterStability() StabilityLevel @@ -114,19 +99,14 @@ func (f exporterFactoryOptionFunc) applyExporterFactoryOption(o *exporterFactory f(o) } -// ExporterCreateDefaultConfigFunc is the equivalent of ExporterFactory.CreateDefaultConfig(). -type ExporterCreateDefaultConfigFunc func() ExporterConfig - -// CreateDefaultConfig implements ExporterFactory.CreateDefaultConfig(). -func (f ExporterCreateDefaultConfigFunc) CreateDefaultConfig() ExporterConfig { - return f() -} +// Deprecated: [v0.67.0] use CreateDefaultConfigFunc. +type ExporterCreateDefaultConfigFunc = CreateDefaultConfigFunc // CreateTracesExporterFunc is the equivalent of ExporterFactory.CreateTracesExporter(). -type CreateTracesExporterFunc func(context.Context, ExporterCreateSettings, ExporterConfig) (TracesExporter, error) +type CreateTracesExporterFunc func(context.Context, ExporterCreateSettings, Config) (TracesExporter, error) // CreateTracesExporter implements ExporterFactory.CreateTracesExporter(). -func (f CreateTracesExporterFunc) CreateTracesExporter(ctx context.Context, set ExporterCreateSettings, cfg ExporterConfig) (TracesExporter, error) { +func (f CreateTracesExporterFunc) CreateTracesExporter(ctx context.Context, set ExporterCreateSettings, cfg Config) (TracesExporter, error) { if f == nil { return nil, ErrDataTypeIsNotSupported } @@ -134,10 +114,10 @@ func (f CreateTracesExporterFunc) CreateTracesExporter(ctx context.Context, set } // CreateMetricsExporterFunc is the equivalent of ExporterFactory.CreateMetricsExporter(). -type CreateMetricsExporterFunc func(context.Context, ExporterCreateSettings, ExporterConfig) (MetricsExporter, error) +type CreateMetricsExporterFunc func(context.Context, ExporterCreateSettings, Config) (MetricsExporter, error) // CreateMetricsExporter implements ExporterFactory.CreateMetricsExporter(). -func (f CreateMetricsExporterFunc) CreateMetricsExporter(ctx context.Context, set ExporterCreateSettings, cfg ExporterConfig) (MetricsExporter, error) { +func (f CreateMetricsExporterFunc) CreateMetricsExporter(ctx context.Context, set ExporterCreateSettings, cfg Config) (MetricsExporter, error) { if f == nil { return nil, ErrDataTypeIsNotSupported } @@ -145,10 +125,10 @@ func (f CreateMetricsExporterFunc) CreateMetricsExporter(ctx context.Context, se } // CreateLogsExporterFunc is the equivalent of ExporterFactory.CreateLogsExporter(). -type CreateLogsExporterFunc func(context.Context, ExporterCreateSettings, ExporterConfig) (LogsExporter, error) +type CreateLogsExporterFunc func(context.Context, ExporterCreateSettings, Config) (LogsExporter, error) // CreateLogsExporter implements ExporterFactory.CreateLogsExporter(). -func (f CreateLogsExporterFunc) CreateLogsExporter(ctx context.Context, set ExporterCreateSettings, cfg ExporterConfig) (LogsExporter, error) { +func (f CreateLogsExporterFunc) CreateLogsExporter(ctx context.Context, set ExporterCreateSettings, cfg Config) (LogsExporter, error) { if f == nil { return nil, ErrDataTypeIsNotSupported } @@ -157,7 +137,6 @@ func (f CreateLogsExporterFunc) CreateLogsExporter(ctx context.Context, set Expo type exporterFactory struct { baseFactory - ExporterCreateDefaultConfigFunc CreateTracesExporterFunc tracesStabilityLevel StabilityLevel CreateMetricsExporterFunc @@ -203,10 +182,12 @@ func WithLogsExporter(createLogsExporter CreateLogsExporterFunc, sl StabilityLev } // NewExporterFactory returns a ExporterFactory. -func NewExporterFactory(cfgType Type, createDefaultConfig ExporterCreateDefaultConfigFunc, options ...ExporterFactoryOption) ExporterFactory { +func NewExporterFactory(cfgType Type, createDefaultConfig CreateDefaultConfigFunc, options ...ExporterFactoryOption) ExporterFactory { f := &exporterFactory{ - baseFactory: baseFactory{cfgType: cfgType}, - ExporterCreateDefaultConfigFunc: createDefaultConfig, + baseFactory: baseFactory{ + cfgType: cfgType, + CreateDefaultConfigFunc: createDefaultConfig, + }, } for _, opt := range options { opt.applyExporterFactoryOption(f) diff --git a/component/exporter_test.go b/component/exporter_test.go index bc9ef0e0335..5bc6a002754 100644 --- a/component/exporter_test.go +++ b/component/exporter_test.go @@ -31,7 +31,7 @@ func TestNewExporterFactory(t *testing.T) { defaultCfg := config.NewExporterSettings(component.NewID(typeStr)) factory := component.NewExporterFactory( typeStr, - func() component.ExporterConfig { return &defaultCfg }) + func() component.Config { return &defaultCfg }) assert.EqualValues(t, typeStr, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateSettings{}, &defaultCfg) @@ -47,7 +47,7 @@ func TestNewExporterFactory_WithOptions(t *testing.T) { defaultCfg := config.NewExporterSettings(component.NewID(typeStr)) factory := component.NewExporterFactory( typeStr, - func() component.ExporterConfig { return &defaultCfg }, + func() component.Config { return &defaultCfg }, component.WithTracesExporter(createTracesExporter, component.StabilityLevelDevelopment), component.WithMetricsExporter(createMetricsExporter, component.StabilityLevelAlpha), component.WithLogsExporter(createLogsExporter, component.StabilityLevelDeprecated)) @@ -67,14 +67,14 @@ func TestNewExporterFactory_WithOptions(t *testing.T) { assert.NoError(t, err) } -func createTracesExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.TracesExporter, error) { +func createTracesExporter(context.Context, component.ExporterCreateSettings, component.Config) (component.TracesExporter, error) { return nil, nil } -func createMetricsExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.MetricsExporter, error) { +func createMetricsExporter(context.Context, component.ExporterCreateSettings, component.Config) (component.MetricsExporter, error) { return nil, nil } -func createLogsExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.LogsExporter, error) { +func createLogsExporter(context.Context, component.ExporterCreateSettings, component.Config) (component.LogsExporter, error) { return nil, nil } diff --git a/component/extension.go b/component/extension.go index 762eea462d5..d866a1b2da9 100644 --- a/component/extension.go +++ b/component/extension.go @@ -16,20 +16,13 @@ package component // import "go.opentelemetry.io/collector/component" import ( "context" - - "go.opentelemetry.io/collector/confmap" ) -// ExtensionConfig is the configuration of a component.Extension. Specific Extension must implement -// this interface and must embed config.ExtensionSettings struct or a struct that extends it. -type ExtensionConfig interface { - Config -} +// Deprecated: [v0.67.0] use Config. +type ExtensionConfig = Config // Deprecated: [v0.67.0] use UnmarshalConfig. -func UnmarshalExtensionConfig(conf *confmap.Conf, cfg ExtensionConfig) error { - return UnmarshalConfig(conf, cfg) -} +var UnmarshalExtensionConfig = UnmarshalConfig // Extension is the interface for objects hosted by the OpenTelemetry Collector that // don't participate directly on data pipelines but provide some functionality @@ -61,19 +54,14 @@ type ExtensionCreateSettings struct { BuildInfo BuildInfo } -// ExtensionCreateDefaultConfigFunc is the equivalent of ExtensionFactory.CreateDefaultConfig() -type ExtensionCreateDefaultConfigFunc func() ExtensionConfig - -// CreateDefaultConfig implements ExtensionFactory.CreateDefaultConfig() -func (f ExtensionCreateDefaultConfigFunc) CreateDefaultConfig() ExtensionConfig { - return f() -} +// Deprecated: [v0.67.0] use CreateDefaultConfigFunc. +type ExtensionCreateDefaultConfigFunc = CreateDefaultConfigFunc // CreateExtensionFunc is the equivalent of ExtensionFactory.CreateExtension() -type CreateExtensionFunc func(context.Context, ExtensionCreateSettings, ExtensionConfig) (Extension, error) +type CreateExtensionFunc func(context.Context, ExtensionCreateSettings, Config) (Extension, error) // CreateExtension implements ExtensionFactory.CreateExtension. -func (f CreateExtensionFunc) CreateExtension(ctx context.Context, set ExtensionCreateSettings, cfg ExtensionConfig) (Extension, error) { +func (f CreateExtensionFunc) CreateExtension(ctx context.Context, set ExtensionCreateSettings, cfg Config) (Extension, error) { return f(ctx, set, cfg) } @@ -81,17 +69,8 @@ func (f CreateExtensionFunc) CreateExtension(ctx context.Context, set ExtensionC type ExtensionFactory interface { Factory - // CreateDefaultConfig creates the default configuration for the Extension. - // This method can be called multiple times depending on the pipeline - // configuration and should not cause side-effects that prevent the creation - // of multiple instances of the Extension. - // The object returned by this method needs to pass the checks implemented by - // 'componenttest.CheckConfigStruct'. It is recommended to have these checks in the - // tests of any implementation of the Factory interface. - CreateDefaultConfig() ExtensionConfig - // CreateExtension creates an extension based on the given config. - CreateExtension(ctx context.Context, set ExtensionCreateSettings, cfg ExtensionConfig) (Extension, error) + CreateExtension(ctx context.Context, set ExtensionCreateSettings, cfg Config) (Extension, error) // ExtensionStability gets the stability level of the Extension. ExtensionStability() StabilityLevel @@ -99,7 +78,6 @@ type ExtensionFactory interface { type extensionFactory struct { baseFactory - ExtensionCreateDefaultConfigFunc CreateExtensionFunc extensionStability StabilityLevel } @@ -111,13 +89,15 @@ func (ef *extensionFactory) ExtensionStability() StabilityLevel { // NewExtensionFactory returns a new ExtensionFactory based on this configuration. func NewExtensionFactory( cfgType Type, - createDefaultConfig ExtensionCreateDefaultConfigFunc, + createDefaultConfig CreateDefaultConfigFunc, createServiceExtension CreateExtensionFunc, sl StabilityLevel) ExtensionFactory { return &extensionFactory{ - baseFactory: baseFactory{cfgType: cfgType}, - ExtensionCreateDefaultConfigFunc: createDefaultConfig, - CreateExtensionFunc: createServiceExtension, - extensionStability: sl, + baseFactory: baseFactory{ + cfgType: cfgType, + CreateDefaultConfigFunc: createDefaultConfig, + }, + CreateExtensionFunc: createServiceExtension, + extensionStability: sl, } } diff --git a/component/extension_test.go b/component/extension_test.go index 9204e90d52b..2e1c8f59327 100644 --- a/component/extension_test.go +++ b/component/extension_test.go @@ -38,8 +38,8 @@ func TestNewExtensionFactory(t *testing.T) { factory := component.NewExtensionFactory( typeStr, - func() component.ExtensionConfig { return &defaultCfg }, - func(ctx context.Context, settings component.ExtensionCreateSettings, extension component.ExtensionConfig) (component.Extension, error) { + func() component.Config { return &defaultCfg }, + func(ctx context.Context, settings component.ExtensionCreateSettings, extension component.Config) (component.Extension, error) { return nopExtensionInstance, nil }, component.StabilityLevelDevelopment) diff --git a/component/processor.go b/component/processor.go index 602ea027abc..cc6d37e1bcd 100644 --- a/component/processor.go +++ b/component/processor.go @@ -17,20 +17,14 @@ package component // import "go.opentelemetry.io/collector/component" import ( "context" - "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/consumer" ) -// ProcessorConfig is the configuration of a component.Processor. Specific Processor must implement -// this interface and must embed ProcessorSettings struct or a struct that extends it. -type ProcessorConfig interface { - Config -} +// Deprecated: [v0.67.0] use Config. +type ProcessorConfig = Config // Deprecated: [v0.67.0] use UnmarshalConfig. -func UnmarshalProcessorConfig(conf *confmap.Conf, cfg ProcessorConfig) error { - return UnmarshalConfig(conf, cfg) -} +var UnmarshalProcessorConfig = UnmarshalConfig // TracesProcessor is a processor that can consume traces. type TracesProcessor interface { @@ -65,19 +59,10 @@ type ProcessorCreateSettings struct { type ProcessorFactory interface { Factory - // CreateDefaultConfig creates the default configuration for the Processor. - // This method can be called multiple times depending on the pipeline - // configuration and should not cause side-effects that prevent the creation - // of multiple instances of the Processor. - // The object returned by this method needs to pass the checks implemented by - // 'componenttest.CheckConfigStruct'. It is recommended to have these checks in the - // tests of any implementation of the Factory interface. - CreateDefaultConfig() ProcessorConfig - // CreateTracesProcessor creates a TracesProcessor based on this config. // If the processor type does not support tracing or if the config is not valid, // an error will be returned instead. - CreateTracesProcessor(ctx context.Context, set ProcessorCreateSettings, cfg ProcessorConfig, nextConsumer consumer.Traces) (TracesProcessor, error) + CreateTracesProcessor(ctx context.Context, set ProcessorCreateSettings, cfg Config, nextConsumer consumer.Traces) (TracesProcessor, error) // TracesProcessorStability gets the stability level of the TracesProcessor. TracesProcessorStability() StabilityLevel @@ -85,7 +70,7 @@ type ProcessorFactory interface { // CreateMetricsProcessor creates a MetricsProcessor based on this config. // If the processor type does not support metrics or if the config is not valid, // an error will be returned instead. - CreateMetricsProcessor(ctx context.Context, set ProcessorCreateSettings, cfg ProcessorConfig, nextConsumer consumer.Metrics) (MetricsProcessor, error) + CreateMetricsProcessor(ctx context.Context, set ProcessorCreateSettings, cfg Config, nextConsumer consumer.Metrics) (MetricsProcessor, error) // MetricsProcessorStability gets the stability level of the MetricsProcessor. MetricsProcessorStability() StabilityLevel @@ -93,19 +78,14 @@ type ProcessorFactory interface { // CreateLogsProcessor creates a LogsProcessor based on the config. // If the processor type does not support logs or if the config is not valid, // an error will be returned instead. - CreateLogsProcessor(ctx context.Context, set ProcessorCreateSettings, cfg ProcessorConfig, nextConsumer consumer.Logs) (LogsProcessor, error) + CreateLogsProcessor(ctx context.Context, set ProcessorCreateSettings, cfg Config, nextConsumer consumer.Logs) (LogsProcessor, error) // LogsProcessorStability gets the stability level of the LogsProcessor. LogsProcessorStability() StabilityLevel } -// ProcessorCreateDefaultConfigFunc is the equivalent of ProcessorFactory.CreateDefaultConfig(). -type ProcessorCreateDefaultConfigFunc func() ProcessorConfig - -// CreateDefaultConfig implements ProcessorFactory.CreateDefaultConfig(). -func (f ProcessorCreateDefaultConfigFunc) CreateDefaultConfig() ProcessorConfig { - return f() -} +// Deprecated: [v0.67.0] use CreateDefaultConfigFunc. +type ProcessorCreateDefaultConfigFunc = CreateDefaultConfigFunc // ProcessorFactoryOption apply changes to ProcessorOptions. type ProcessorFactoryOption interface { @@ -123,13 +103,13 @@ func (f processorFactoryOptionFunc) applyProcessorFactoryOption(o *processorFact } // CreateTracesProcessorFunc is the equivalent of ProcessorFactory.CreateTracesProcessor(). -type CreateTracesProcessorFunc func(context.Context, ProcessorCreateSettings, ProcessorConfig, consumer.Traces) (TracesProcessor, error) +type CreateTracesProcessorFunc func(context.Context, ProcessorCreateSettings, Config, consumer.Traces) (TracesProcessor, error) // CreateTracesProcessor implements ProcessorFactory.CreateTracesProcessor(). func (f CreateTracesProcessorFunc) CreateTracesProcessor( ctx context.Context, set ProcessorCreateSettings, - cfg ProcessorConfig, + cfg Config, nextConsumer consumer.Traces) (TracesProcessor, error) { if f == nil { return nil, ErrDataTypeIsNotSupported @@ -138,13 +118,13 @@ func (f CreateTracesProcessorFunc) CreateTracesProcessor( } // CreateMetricsProcessorFunc is the equivalent of ProcessorFactory.CreateMetricsProcessor(). -type CreateMetricsProcessorFunc func(context.Context, ProcessorCreateSettings, ProcessorConfig, consumer.Metrics) (MetricsProcessor, error) +type CreateMetricsProcessorFunc func(context.Context, ProcessorCreateSettings, Config, consumer.Metrics) (MetricsProcessor, error) // CreateMetricsProcessor implements ProcessorFactory.CreateMetricsProcessor(). func (f CreateMetricsProcessorFunc) CreateMetricsProcessor( ctx context.Context, set ProcessorCreateSettings, - cfg ProcessorConfig, + cfg Config, nextConsumer consumer.Metrics, ) (MetricsProcessor, error) { if f == nil { @@ -154,13 +134,13 @@ func (f CreateMetricsProcessorFunc) CreateMetricsProcessor( } // CreateLogsProcessorFunc is the equivalent of ProcessorFactory.CreateLogsProcessor(). -type CreateLogsProcessorFunc func(context.Context, ProcessorCreateSettings, ProcessorConfig, consumer.Logs) (LogsProcessor, error) +type CreateLogsProcessorFunc func(context.Context, ProcessorCreateSettings, Config, consumer.Logs) (LogsProcessor, error) // CreateLogsProcessor implements ProcessorFactory.CreateLogsProcessor(). func (f CreateLogsProcessorFunc) CreateLogsProcessor( ctx context.Context, set ProcessorCreateSettings, - cfg ProcessorConfig, + cfg Config, nextConsumer consumer.Logs, ) (LogsProcessor, error) { if f == nil { @@ -171,7 +151,6 @@ func (f CreateLogsProcessorFunc) CreateLogsProcessor( type processorFactory struct { baseFactory - ProcessorCreateDefaultConfigFunc CreateTracesProcessorFunc tracesStabilityLevel StabilityLevel CreateMetricsProcessorFunc @@ -217,10 +196,12 @@ func WithLogsProcessor(createLogsProcessor CreateLogsProcessorFunc, sl Stability } // NewProcessorFactory returns a ProcessorFactory. -func NewProcessorFactory(cfgType Type, createDefaultConfig ProcessorCreateDefaultConfigFunc, options ...ProcessorFactoryOption) ProcessorFactory { +func NewProcessorFactory(cfgType Type, createDefaultConfig CreateDefaultConfigFunc, options ...ProcessorFactoryOption) ProcessorFactory { f := &processorFactory{ - baseFactory: baseFactory{cfgType: cfgType}, - ProcessorCreateDefaultConfigFunc: createDefaultConfig, + baseFactory: baseFactory{ + cfgType: cfgType, + CreateDefaultConfigFunc: createDefaultConfig, + }, } for _, opt := range options { opt.applyProcessorFactoryOption(f) diff --git a/component/processor_test.go b/component/processor_test.go index 2fa697f1f1f..8b1c5815be5 100644 --- a/component/processor_test.go +++ b/component/processor_test.go @@ -32,7 +32,7 @@ func TestNewProcessorFactory(t *testing.T) { defaultCfg := config.NewProcessorSettings(component.NewID(typeStr)) factory := component.NewProcessorFactory( typeStr, - func() component.ProcessorConfig { return &defaultCfg }) + func() component.Config { return &defaultCfg }) assert.EqualValues(t, typeStr, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateSettings{}, &defaultCfg, nil) @@ -48,7 +48,7 @@ func TestNewProcessorFactory_WithOptions(t *testing.T) { defaultCfg := config.NewProcessorSettings(component.NewID(typeStr)) factory := component.NewProcessorFactory( typeStr, - func() component.ProcessorConfig { return &defaultCfg }, + func() component.Config { return &defaultCfg }, component.WithTracesProcessor(createTracesProcessor, component.StabilityLevelAlpha), component.WithMetricsProcessor(createMetricsProcessor, component.StabilityLevelBeta), component.WithLogsProcessor(createLogsProcessor, component.StabilityLevelUnmaintained)) @@ -68,14 +68,14 @@ func TestNewProcessorFactory_WithOptions(t *testing.T) { assert.NoError(t, err) } -func createTracesProcessor(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Traces) (component.TracesProcessor, error) { +func createTracesProcessor(context.Context, component.ProcessorCreateSettings, component.Config, consumer.Traces) (component.TracesProcessor, error) { return nil, nil } -func createMetricsProcessor(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Metrics) (component.MetricsProcessor, error) { +func createMetricsProcessor(context.Context, component.ProcessorCreateSettings, component.Config, consumer.Metrics) (component.MetricsProcessor, error) { return nil, nil } -func createLogsProcessor(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Logs) (component.LogsProcessor, error) { +func createLogsProcessor(context.Context, component.ProcessorCreateSettings, component.Config, consumer.Logs) (component.LogsProcessor, error) { return nil, nil } diff --git a/component/receiver.go b/component/receiver.go index bf9b7e8ca3b..9253b31efc7 100644 --- a/component/receiver.go +++ b/component/receiver.go @@ -17,20 +17,14 @@ package component // import "go.opentelemetry.io/collector/component" import ( "context" - "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/consumer" ) -// ReceiverConfig is the configuration of a component.Receiver. Specific Extension must implement -// this interface and must embed ReceiverSettings struct or a struct that extends it. -type ReceiverConfig interface { - Config -} +// Deprecated: [v0.67.0] use Config. +type ReceiverConfig = Config // Deprecated: [v0.67.0] use UnmarshalConfig. -func UnmarshalReceiverConfig(conf *confmap.Conf, cfg ReceiverConfig) error { - return UnmarshalConfig(conf, cfg) -} +var UnmarshalReceiverConfig = UnmarshalConfig // A TracesReceiver receives traces. // Its purpose is to translate data from any format to the collector's internal trace format. @@ -74,19 +68,10 @@ type ReceiverCreateSettings struct { type ReceiverFactory interface { Factory - // CreateDefaultConfig creates the default configuration for the Receiver. - // This method can be called multiple times depending on the pipeline - // configuration and should not cause side-effects that prevent the creation - // of multiple instances of the Receiver. - // The object returned by this method needs to pass the checks implemented by - // 'componenttest.CheckConfigStruct'. It is recommended to have these checks in the - // tests of any implementation of the Factory interface. - CreateDefaultConfig() ReceiverConfig - // CreateTracesReceiver creates a TracesReceiver based on this config. // If the receiver type does not support tracing or if the config is not valid // an error will be returned instead. - CreateTracesReceiver(ctx context.Context, set ReceiverCreateSettings, cfg ReceiverConfig, nextConsumer consumer.Traces) (TracesReceiver, error) + CreateTracesReceiver(ctx context.Context, set ReceiverCreateSettings, cfg Config, nextConsumer consumer.Traces) (TracesReceiver, error) // TracesReceiverStability gets the stability level of the TracesReceiver. TracesReceiverStability() StabilityLevel @@ -94,7 +79,7 @@ type ReceiverFactory interface { // CreateMetricsReceiver creates a MetricsReceiver based on this config. // If the receiver type does not support metrics or if the config is not valid // an error will be returned instead. - CreateMetricsReceiver(ctx context.Context, set ReceiverCreateSettings, cfg ReceiverConfig, nextConsumer consumer.Metrics) (MetricsReceiver, error) + CreateMetricsReceiver(ctx context.Context, set ReceiverCreateSettings, cfg Config, nextConsumer consumer.Metrics) (MetricsReceiver, error) // MetricsReceiverStability gets the stability level of the MetricsReceiver. MetricsReceiverStability() StabilityLevel @@ -102,7 +87,7 @@ type ReceiverFactory interface { // CreateLogsReceiver creates a LogsReceiver based on this config. // If the receiver type does not support the data type or if the config is not valid // an error will be returned instead. - CreateLogsReceiver(ctx context.Context, set ReceiverCreateSettings, cfg ReceiverConfig, nextConsumer consumer.Logs) (LogsReceiver, error) + CreateLogsReceiver(ctx context.Context, set ReceiverCreateSettings, cfg Config, nextConsumer consumer.Logs) (LogsReceiver, error) // LogsReceiverStability gets the stability level of the LogsReceiver. LogsReceiverStability() StabilityLevel @@ -123,22 +108,17 @@ func (f receiverFactoryOptionFunc) applyReceiverFactoryOption(o *receiverFactory f(o) } -// ReceiverCreateDefaultConfigFunc is the equivalent of ReceiverFactory.CreateDefaultConfig(). -type ReceiverCreateDefaultConfigFunc func() ReceiverConfig - -// CreateDefaultConfig implements ReceiverFactory.CreateDefaultConfig(). -func (f ReceiverCreateDefaultConfigFunc) CreateDefaultConfig() ReceiverConfig { - return f() -} +// Deprecated: [v0.67.0] use CreateDefaultConfigFunc. +type ReceiverCreateDefaultConfigFunc = CreateDefaultConfigFunc // CreateTracesReceiverFunc is the equivalent of ReceiverFactory.CreateTracesReceiver(). -type CreateTracesReceiverFunc func(context.Context, ReceiverCreateSettings, ReceiverConfig, consumer.Traces) (TracesReceiver, error) +type CreateTracesReceiverFunc func(context.Context, ReceiverCreateSettings, Config, consumer.Traces) (TracesReceiver, error) // CreateTracesReceiver implements ReceiverFactory.CreateTracesReceiver(). func (f CreateTracesReceiverFunc) CreateTracesReceiver( ctx context.Context, set ReceiverCreateSettings, - cfg ReceiverConfig, + cfg Config, nextConsumer consumer.Traces) (TracesReceiver, error) { if f == nil { return nil, ErrDataTypeIsNotSupported @@ -147,13 +127,13 @@ func (f CreateTracesReceiverFunc) CreateTracesReceiver( } // CreateMetricsReceiverFunc is the equivalent of ReceiverFactory.CreateMetricsReceiver(). -type CreateMetricsReceiverFunc func(context.Context, ReceiverCreateSettings, ReceiverConfig, consumer.Metrics) (MetricsReceiver, error) +type CreateMetricsReceiverFunc func(context.Context, ReceiverCreateSettings, Config, consumer.Metrics) (MetricsReceiver, error) // CreateMetricsReceiver implements ReceiverFactory.CreateMetricsReceiver(). func (f CreateMetricsReceiverFunc) CreateMetricsReceiver( ctx context.Context, set ReceiverCreateSettings, - cfg ReceiverConfig, + cfg Config, nextConsumer consumer.Metrics, ) (MetricsReceiver, error) { if f == nil { @@ -163,13 +143,13 @@ func (f CreateMetricsReceiverFunc) CreateMetricsReceiver( } // CreateLogsReceiverFunc is the equivalent of ReceiverFactory.CreateLogsReceiver(). -type CreateLogsReceiverFunc func(context.Context, ReceiverCreateSettings, ReceiverConfig, consumer.Logs) (LogsReceiver, error) +type CreateLogsReceiverFunc func(context.Context, ReceiverCreateSettings, Config, consumer.Logs) (LogsReceiver, error) // CreateLogsReceiver implements ReceiverFactory.CreateLogsReceiver(). func (f CreateLogsReceiverFunc) CreateLogsReceiver( ctx context.Context, set ReceiverCreateSettings, - cfg ReceiverConfig, + cfg Config, nextConsumer consumer.Logs, ) (LogsReceiver, error) { if f == nil { @@ -180,7 +160,6 @@ func (f CreateLogsReceiverFunc) CreateLogsReceiver( type receiverFactory struct { baseFactory - ReceiverCreateDefaultConfigFunc CreateTracesReceiverFunc tracesStabilityLevel StabilityLevel CreateMetricsReceiverFunc @@ -226,10 +205,12 @@ func WithLogsReceiver(createLogsReceiver CreateLogsReceiverFunc, sl StabilityLev } // NewReceiverFactory returns a ReceiverFactory. -func NewReceiverFactory(cfgType Type, createDefaultConfig ReceiverCreateDefaultConfigFunc, options ...ReceiverFactoryOption) ReceiverFactory { +func NewReceiverFactory(cfgType Type, createDefaultConfig CreateDefaultConfigFunc, options ...ReceiverFactoryOption) ReceiverFactory { f := &receiverFactory{ - baseFactory: baseFactory{cfgType: cfgType}, - ReceiverCreateDefaultConfigFunc: createDefaultConfig, + baseFactory: baseFactory{ + cfgType: cfgType, + CreateDefaultConfigFunc: createDefaultConfig, + }, } for _, opt := range options { opt.applyReceiverFactoryOption(f) diff --git a/component/receiver_test.go b/component/receiver_test.go index 01d03e7f7f4..0d440bd04e7 100644 --- a/component/receiver_test.go +++ b/component/receiver_test.go @@ -32,7 +32,7 @@ func TestNewReceiverFactory(t *testing.T) { defaultCfg := config.NewReceiverSettings(component.NewID(typeStr)) factory := component.NewReceiverFactory( typeStr, - func() component.ReceiverConfig { return &defaultCfg }) + func() component.Config { return &defaultCfg }) assert.EqualValues(t, typeStr, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateTracesReceiver(context.Background(), component.ReceiverCreateSettings{}, &defaultCfg, nil) @@ -48,7 +48,7 @@ func TestNewReceiverFactory_WithOptions(t *testing.T) { defaultCfg := config.NewReceiverSettings(component.NewID(typeStr)) factory := component.NewReceiverFactory( typeStr, - func() component.ReceiverConfig { return &defaultCfg }, + func() component.Config { return &defaultCfg }, component.WithTracesReceiver(createTracesReceiver, component.StabilityLevelDeprecated), component.WithMetricsReceiver(createMetricsReceiver, component.StabilityLevelAlpha), component.WithLogsReceiver(createLogsReceiver, component.StabilityLevelStable)) @@ -68,14 +68,14 @@ func TestNewReceiverFactory_WithOptions(t *testing.T) { assert.NoError(t, err) } -func createTracesReceiver(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Traces) (component.TracesReceiver, error) { +func createTracesReceiver(context.Context, component.ReceiverCreateSettings, component.Config, consumer.Traces) (component.TracesReceiver, error) { return nil, nil } -func createMetricsReceiver(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Metrics) (component.MetricsReceiver, error) { +func createMetricsReceiver(context.Context, component.ReceiverCreateSettings, component.Config, consumer.Metrics) (component.MetricsReceiver, error) { return nil, nil } -func createLogsReceiver(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Logs) (component.LogsReceiver, error) { +func createLogsReceiver(context.Context, component.ReceiverCreateSettings, component.Config, consumer.Logs) (component.LogsReceiver, error) { return nil, nil } diff --git a/config/exporter.go b/config/exporter.go index 1b3176fb672..15cbe686320 100644 --- a/config/exporter.go +++ b/config/exporter.go @@ -33,4 +33,4 @@ func NewExporterSettings(id component.ID) ExporterSettings { return ExporterSettings{settings: newSettings(id)} } -var _ component.ExporterConfig = (*ExporterSettings)(nil) +var _ component.Config = (*ExporterSettings)(nil) diff --git a/config/extension.go b/config/extension.go index 209a06222d5..edb4967d2c5 100644 --- a/config/extension.go +++ b/config/extension.go @@ -32,4 +32,4 @@ func NewExtensionSettings(id component.ID) ExtensionSettings { return ExtensionSettings{settings: newSettings(id)} } -var _ component.ExtensionConfig = (*ExtensionSettings)(nil) +var _ component.Config = (*ExtensionSettings)(nil) diff --git a/config/processor.go b/config/processor.go index 5950c667516..943ca28a3d3 100644 --- a/config/processor.go +++ b/config/processor.go @@ -32,4 +32,4 @@ func NewProcessorSettings(id component.ID) ProcessorSettings { return ProcessorSettings{settings: newSettings(id)} } -var _ component.ProcessorConfig = (*ProcessorSettings)(nil) +var _ component.Config = (*ProcessorSettings)(nil) diff --git a/config/receiver.go b/config/receiver.go index 2c29d7db1b6..5bacff4976d 100644 --- a/config/receiver.go +++ b/config/receiver.go @@ -32,4 +32,4 @@ func NewReceiverSettings(id component.ID) ReceiverSettings { return ReceiverSettings{settings: newSettings(id)} } -var _ component.ReceiverConfig = (*ReceiverSettings)(nil) +var _ component.Config = (*ReceiverSettings)(nil) diff --git a/connector/connector.go b/connector/connector.go index 749e30ce70a..f565d2dec7c 100644 --- a/connector/connector.go +++ b/connector/connector.go @@ -42,15 +42,6 @@ type CreateSettings struct { // use the NewFactory to implement it. type Factory interface { component.Factory - - // CreateDefaultConfig creates the default configuration for the Connector. - // This method can be called multiple times depending on the pipeline - // configuration and should not cause side-effects that prevent the creation - // of multiple instances of the Connector. - // The object returned by this method needs to pass the checks implemented by - // 'configtest.CheckConfigStruct'. It is recommended to have these checks in the - // tests of any implementation of the Factory interface. - CreateDefaultConfig() component.Config } // FactoryOption applies changes to Factory. @@ -82,6 +73,12 @@ func (f *factory) Type() component.Type { return f.cfgType } +// CreateDefaultConfig creates the default configuration for the Component. +// TODO: Remove this when we remove the private func from component.Factory and add it to every specialized Factory. +func (f *factory) CreateDefaultConfig() component.Config { + return f.CreateDefaultConfigFunc() +} + // NewFactory returns a Factory. func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefaultConfigFunc, options ...FactoryOption) Factory { f := &factory{ diff --git a/exporter/exporterhelper/common.go b/exporter/exporterhelper/common.go index 68d32750462..e98628b01b9 100644 --- a/exporter/exporterhelper/common.go +++ b/exporter/exporterhelper/common.go @@ -155,7 +155,7 @@ type baseExporter struct { qrSender *queuedRetrySender } -func newBaseExporter(cfg component.ExporterConfig, set component.ExporterCreateSettings, bs *baseSettings, signal component.DataType, reqUnmarshaler internal.RequestUnmarshaler) (*baseExporter, error) { +func newBaseExporter(cfg component.Config, set component.ExporterCreateSettings, bs *baseSettings, signal component.DataType, reqUnmarshaler internal.RequestUnmarshaler) (*baseExporter, error) { be := &baseExporter{} var err error diff --git a/exporter/exporterhelper/logs.go b/exporter/exporterhelper/logs.go index 29a558520e0..92d2f1b718f 100644 --- a/exporter/exporterhelper/logs.go +++ b/exporter/exporterhelper/logs.go @@ -81,7 +81,7 @@ type logsExporter struct { func NewLogsExporter( _ context.Context, set component.ExporterCreateSettings, - cfg component.ExporterConfig, + cfg component.Config, pusher consumer.ConsumeLogsFunc, options ...Option, ) (component.LogsExporter, error) { diff --git a/exporter/exporterhelper/metrics.go b/exporter/exporterhelper/metrics.go index 33d81d64fa5..a81c674d43f 100644 --- a/exporter/exporterhelper/metrics.go +++ b/exporter/exporterhelper/metrics.go @@ -82,7 +82,7 @@ type metricsExporter struct { func NewMetricsExporter( _ context.Context, set component.ExporterCreateSettings, - cfg component.ExporterConfig, + cfg component.Config, pusher consumer.ConsumeMetricsFunc, options ...Option, ) (component.MetricsExporter, error) { diff --git a/exporter/exporterhelper/traces.go b/exporter/exporterhelper/traces.go index a2a2c311741..ce882e3fe54 100644 --- a/exporter/exporterhelper/traces.go +++ b/exporter/exporterhelper/traces.go @@ -82,7 +82,7 @@ type traceExporter struct { func NewTracesExporter( _ context.Context, set component.ExporterCreateSettings, - cfg component.ExporterConfig, + cfg component.Config, pusher consumer.ConsumeTracesFunc, options ...Option, ) (component.TracesExporter, error) { diff --git a/exporter/loggingexporter/config.go b/exporter/loggingexporter/config.go index 7dbff1bba25..076f5cc0bfc 100644 --- a/exporter/loggingexporter/config.go +++ b/exporter/loggingexporter/config.go @@ -56,7 +56,7 @@ type Config struct { warnLogLevel bool } -var _ component.ExporterConfig = (*Config)(nil) +var _ component.Config = (*Config)(nil) var _ confmap.Unmarshaler = (*Config)(nil) func mapLevel(level zapcore.Level) (configtelemetry.Level, error) { diff --git a/exporter/loggingexporter/factory.go b/exporter/loggingexporter/factory.go index 0b500c2bda3..3941138cc4f 100644 --- a/exporter/loggingexporter/factory.go +++ b/exporter/loggingexporter/factory.go @@ -49,7 +49,7 @@ func NewFactory() component.ExporterFactory { ) } -func createDefaultConfig() component.ExporterConfig { +func createDefaultConfig() component.Config { return &Config{ ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)), LogLevel: zapcore.InfoLevel, @@ -59,7 +59,7 @@ func createDefaultConfig() component.ExporterConfig { } } -func createTracesExporter(ctx context.Context, set component.ExporterCreateSettings, config component.ExporterConfig) (component.TracesExporter, error) { +func createTracesExporter(ctx context.Context, set component.ExporterCreateSettings, config component.Config) (component.TracesExporter, error) { cfg := config.(*Config) exporterLogger := createLogger(cfg, set.TelemetrySettings.Logger) s := newLoggingExporter(exporterLogger, cfg.Verbosity) @@ -74,7 +74,7 @@ func createTracesExporter(ctx context.Context, set component.ExporterCreateSetti ) } -func createMetricsExporter(ctx context.Context, set component.ExporterCreateSettings, config component.ExporterConfig) (component.MetricsExporter, error) { +func createMetricsExporter(ctx context.Context, set component.ExporterCreateSettings, config component.Config) (component.MetricsExporter, error) { cfg := config.(*Config) exporterLogger := createLogger(cfg, set.TelemetrySettings.Logger) s := newLoggingExporter(exporterLogger, cfg.Verbosity) @@ -89,7 +89,7 @@ func createMetricsExporter(ctx context.Context, set component.ExporterCreateSett ) } -func createLogsExporter(ctx context.Context, set component.ExporterCreateSettings, config component.ExporterConfig) (component.LogsExporter, error) { +func createLogsExporter(ctx context.Context, set component.ExporterCreateSettings, config component.Config) (component.LogsExporter, error) { cfg := config.(*Config) exporterLogger := createLogger(cfg, set.TelemetrySettings.Logger) s := newLoggingExporter(exporterLogger, cfg.Verbosity) diff --git a/exporter/otlpexporter/config.go b/exporter/otlpexporter/config.go index c15770fa9eb..72be78a2f25 100644 --- a/exporter/otlpexporter/config.go +++ b/exporter/otlpexporter/config.go @@ -33,7 +33,7 @@ type Config struct { configgrpc.GRPCClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. } -var _ component.ExporterConfig = (*Config)(nil) +var _ component.Config = (*Config)(nil) // Validate checks if the exporter configuration is valid func (cfg *Config) Validate() error { diff --git a/exporter/otlpexporter/factory.go b/exporter/otlpexporter/factory.go index 3a140974375..39b450fd206 100644 --- a/exporter/otlpexporter/factory.go +++ b/exporter/otlpexporter/factory.go @@ -41,7 +41,7 @@ func NewFactory() component.ExporterFactory { ) } -func createDefaultConfig() component.ExporterConfig { +func createDefaultConfig() component.Config { return &Config{ ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)), TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(), @@ -60,7 +60,7 @@ func createDefaultConfig() component.ExporterConfig { func createTracesExporter( ctx context.Context, set component.ExporterCreateSettings, - cfg component.ExporterConfig, + cfg component.Config, ) (component.TracesExporter, error) { oce, err := newExporter(cfg, set) if err != nil { @@ -80,7 +80,7 @@ func createTracesExporter( func createMetricsExporter( ctx context.Context, set component.ExporterCreateSettings, - cfg component.ExporterConfig, + cfg component.Config, ) (component.MetricsExporter, error) { oce, err := newExporter(cfg, set) if err != nil { @@ -101,7 +101,7 @@ func createMetricsExporter( func createLogsExporter( ctx context.Context, set component.ExporterCreateSettings, - cfg component.ExporterConfig, + cfg component.Config, ) (component.LogsExporter, error) { oce, err := newExporter(cfg, set) if err != nil { diff --git a/exporter/otlpexporter/otlp.go b/exporter/otlpexporter/otlp.go index ea619888940..08e36a2fbef 100644 --- a/exporter/otlpexporter/otlp.go +++ b/exporter/otlpexporter/otlp.go @@ -58,7 +58,7 @@ type exporter struct { // Crete new exporter and start it. The exporter will begin connecting but // this function may return before the connection is established. -func newExporter(cfg component.ExporterConfig, set component.ExporterCreateSettings) (*exporter, error) { +func newExporter(cfg component.Config, set component.ExporterCreateSettings) (*exporter, error) { oCfg := cfg.(*Config) if oCfg.Endpoint == "" { diff --git a/exporter/otlphttpexporter/config.go b/exporter/otlphttpexporter/config.go index 04fbf7d4bc4..b33480edfe5 100644 --- a/exporter/otlphttpexporter/config.go +++ b/exporter/otlphttpexporter/config.go @@ -40,7 +40,7 @@ type Config struct { LogsEndpoint string `mapstructure:"logs_endpoint"` } -var _ component.ExporterConfig = (*Config)(nil) +var _ component.Config = (*Config)(nil) // Validate checks if the exporter configuration is valid func (cfg *Config) Validate() error { diff --git a/exporter/otlphttpexporter/factory.go b/exporter/otlphttpexporter/factory.go index 5048d920f0d..b720e442af8 100644 --- a/exporter/otlphttpexporter/factory.go +++ b/exporter/otlphttpexporter/factory.go @@ -44,7 +44,7 @@ func NewFactory() component.ExporterFactory { ) } -func createDefaultConfig() component.ExporterConfig { +func createDefaultConfig() component.Config { return &Config{ ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)), RetrySettings: exporterhelper.NewDefaultRetrySettings(), @@ -79,7 +79,7 @@ func composeSignalURL(oCfg *Config, signalOverrideURL string, signalName string) func createTracesExporter( ctx context.Context, set component.ExporterCreateSettings, - cfg component.ExporterConfig, + cfg component.Config, ) (component.TracesExporter, error) { oce, err := newExporter(cfg, set) if err != nil { @@ -105,7 +105,7 @@ func createTracesExporter( func createMetricsExporter( ctx context.Context, set component.ExporterCreateSettings, - cfg component.ExporterConfig, + cfg component.Config, ) (component.MetricsExporter, error) { oce, err := newExporter(cfg, set) if err != nil { @@ -131,7 +131,7 @@ func createMetricsExporter( func createLogsExporter( ctx context.Context, set component.ExporterCreateSettings, - cfg component.ExporterConfig, + cfg component.Config, ) (component.LogsExporter, error) { oce, err := newExporter(cfg, set) if err != nil { diff --git a/exporter/otlphttpexporter/otlp.go b/exporter/otlphttpexporter/otlp.go index 95ea2c4118b..e98767dcff9 100644 --- a/exporter/otlphttpexporter/otlp.go +++ b/exporter/otlphttpexporter/otlp.go @@ -60,7 +60,7 @@ const ( ) // Create new exporter. -func newExporter(cfg component.ExporterConfig, set component.ExporterCreateSettings) (*exporter, error) { +func newExporter(cfg component.Config, set component.ExporterCreateSettings) (*exporter, error) { oCfg := cfg.(*Config) if oCfg.Endpoint != "" { diff --git a/exporter/otlphttpexporter/otlp_test.go b/exporter/otlphttpexporter/otlp_test.go index 83361af35f2..7036b1370f7 100644 --- a/exporter/otlphttpexporter/otlp_test.go +++ b/exporter/otlphttpexporter/otlp_test.go @@ -332,7 +332,7 @@ func startLogsExporter(t *testing.T, baseURL string, overrideURL string) compone return exp } -func createExporterConfig(baseURL string, defaultCfg component.ExporterConfig) *Config { +func createExporterConfig(baseURL string, defaultCfg component.Config) *Config { cfg := defaultCfg.(*Config) cfg.Endpoint = baseURL cfg.QueueSettings.Enabled = false @@ -364,7 +364,7 @@ func startLogsReceiver(t *testing.T, addr string, next consumer.Logs) { startAndCleanup(t, recv) } -func createReceiverConfig(addr string, defaultCfg component.ReceiverConfig) *otlpreceiver.Config { +func createReceiverConfig(addr string, defaultCfg component.Config) *otlpreceiver.Config { cfg := defaultCfg.(*otlpreceiver.Config) cfg.HTTP.Endpoint = addr cfg.GRPC = nil diff --git a/extension/ballastextension/factory.go b/extension/ballastextension/factory.go index 6d5687c3286..b37d17d88db 100644 --- a/extension/ballastextension/factory.go +++ b/extension/ballastextension/factory.go @@ -35,12 +35,12 @@ func NewFactory() component.ExtensionFactory { return component.NewExtensionFactory(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta) } -func createDefaultConfig() component.ExtensionConfig { +func createDefaultConfig() component.Config { return &Config{ ExtensionSettings: config.NewExtensionSettings(component.NewID(typeStr)), } } -func createExtension(_ context.Context, set component.ExtensionCreateSettings, cfg component.ExtensionConfig) (component.Extension, error) { +func createExtension(_ context.Context, set component.ExtensionCreateSettings, cfg component.Config) (component.Extension, error) { return newMemoryBallast(cfg.(*Config), set.Logger, memHandler), nil } diff --git a/extension/zpagesextension/config.go b/extension/zpagesextension/config.go index 8774f870d79..538de90474c 100644 --- a/extension/zpagesextension/config.go +++ b/extension/zpagesextension/config.go @@ -32,7 +32,7 @@ type Config struct { TCPAddr confignet.TCPAddr `mapstructure:",squash"` } -var _ component.ExtensionConfig = (*Config)(nil) +var _ component.Config = (*Config)(nil) // Validate checks if the extension configuration is valid func (cfg *Config) Validate() error { diff --git a/extension/zpagesextension/factory.go b/extension/zpagesextension/factory.go index 5d7a458c5d7..fecaa708bba 100644 --- a/extension/zpagesextension/factory.go +++ b/extension/zpagesextension/factory.go @@ -34,7 +34,7 @@ func NewFactory() component.ExtensionFactory { return component.NewExtensionFactory(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta) } -func createDefaultConfig() component.ExtensionConfig { +func createDefaultConfig() component.Config { return &Config{ ExtensionSettings: config.NewExtensionSettings(component.NewID(typeStr)), TCPAddr: confignet.TCPAddr{ @@ -44,6 +44,6 @@ func createDefaultConfig() component.ExtensionConfig { } // createExtension creates the extension based on this config. -func createExtension(_ context.Context, set component.ExtensionCreateSettings, cfg component.ExtensionConfig) (component.Extension, error) { +func createExtension(_ context.Context, set component.ExtensionCreateSettings, cfg component.Config) (component.Extension, error) { return newServer(cfg.(*Config), set.TelemetrySettings), nil } diff --git a/processor/batchprocessor/config.go b/processor/batchprocessor/config.go index 664e1bbcd07..eb8dedccb3d 100644 --- a/processor/batchprocessor/config.go +++ b/processor/batchprocessor/config.go @@ -38,7 +38,7 @@ type Config struct { SendBatchMaxSize uint32 `mapstructure:"send_batch_max_size"` } -var _ component.ProcessorConfig = (*Config)(nil) +var _ component.Config = (*Config)(nil) // Validate checks if the processor configuration is valid func (cfg *Config) Validate() error { diff --git a/processor/batchprocessor/factory.go b/processor/batchprocessor/factory.go index 7e2f2ac6342..266bc99c0f6 100644 --- a/processor/batchprocessor/factory.go +++ b/processor/batchprocessor/factory.go @@ -42,7 +42,7 @@ func NewFactory() component.ProcessorFactory { component.WithLogsProcessor(createLogsProcessor, component.StabilityLevelStable)) } -func createDefaultConfig() component.ProcessorConfig { +func createDefaultConfig() component.Config { return &Config{ ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)), SendBatchSize: defaultSendBatchSize, @@ -53,7 +53,7 @@ func createDefaultConfig() component.ProcessorConfig { func createTracesProcessor( _ context.Context, set component.ProcessorCreateSettings, - cfg component.ProcessorConfig, + cfg component.Config, nextConsumer consumer.Traces, ) (component.TracesProcessor, error) { level := set.MetricsLevel @@ -63,7 +63,7 @@ func createTracesProcessor( func createMetricsProcessor( _ context.Context, set component.ProcessorCreateSettings, - cfg component.ProcessorConfig, + cfg component.Config, nextConsumer consumer.Metrics, ) (component.MetricsProcessor, error) { level := set.MetricsLevel @@ -73,7 +73,7 @@ func createMetricsProcessor( func createLogsProcessor( _ context.Context, set component.ProcessorCreateSettings, - cfg component.ProcessorConfig, + cfg component.Config, nextConsumer consumer.Logs, ) (component.LogsProcessor, error) { level := set.MetricsLevel diff --git a/processor/memorylimiterprocessor/config.go b/processor/memorylimiterprocessor/config.go index 9c7e5f2d128..9cd03f28cf4 100644 --- a/processor/memorylimiterprocessor/config.go +++ b/processor/memorylimiterprocessor/config.go @@ -50,7 +50,7 @@ type Config struct { MemorySpikePercentage uint32 `mapstructure:"spike_limit_percentage"` } -var _ component.ProcessorConfig = (*Config)(nil) +var _ component.Config = (*Config)(nil) // Validate checks if the processor configuration is valid func (cfg *Config) Validate() error { diff --git a/processor/memorylimiterprocessor/factory.go b/processor/memorylimiterprocessor/factory.go index 735b77bc234..f5291c080b4 100644 --- a/processor/memorylimiterprocessor/factory.go +++ b/processor/memorylimiterprocessor/factory.go @@ -34,14 +34,14 @@ var processorCapabilities = consumer.Capabilities{MutatesData: false} type factory struct { // memoryLimiters stores memoryLimiter instances with unique configs that multiple processors can reuse. // This avoids running multiple memory checks (ie: GC) for every processor using the same processor config. - memoryLimiters map[component.ProcessorConfig]*memoryLimiter + memoryLimiters map[component.Config]*memoryLimiter lock sync.Mutex } // NewFactory returns a new factory for the Memory Limiter processor. func NewFactory() component.ProcessorFactory { f := &factory{ - memoryLimiters: map[component.ProcessorConfig]*memoryLimiter{}, + memoryLimiters: map[component.Config]*memoryLimiter{}, } return component.NewProcessorFactory( typeStr, @@ -53,7 +53,7 @@ func NewFactory() component.ProcessorFactory { // CreateDefaultConfig creates the default configuration for processor. Notice // that the default configuration is expected to fail for this processor. -func createDefaultConfig() component.ProcessorConfig { +func createDefaultConfig() component.Config { return &Config{ ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)), } @@ -62,7 +62,7 @@ func createDefaultConfig() component.ProcessorConfig { func (f *factory) createTracesProcessor( ctx context.Context, set component.ProcessorCreateSettings, - cfg component.ProcessorConfig, + cfg component.Config, nextConsumer consumer.Traces, ) (component.TracesProcessor, error) { memLimiter, err := f.getMemoryLimiter(set, cfg) @@ -79,7 +79,7 @@ func (f *factory) createTracesProcessor( func (f *factory) createMetricsProcessor( ctx context.Context, set component.ProcessorCreateSettings, - cfg component.ProcessorConfig, + cfg component.Config, nextConsumer consumer.Metrics, ) (component.MetricsProcessor, error) { memLimiter, err := f.getMemoryLimiter(set, cfg) @@ -96,7 +96,7 @@ func (f *factory) createMetricsProcessor( func (f *factory) createLogsProcessor( ctx context.Context, set component.ProcessorCreateSettings, - cfg component.ProcessorConfig, + cfg component.Config, nextConsumer consumer.Logs, ) (component.LogsProcessor, error) { memLimiter, err := f.getMemoryLimiter(set, cfg) @@ -112,7 +112,7 @@ func (f *factory) createLogsProcessor( // getMemoryLimiter checks if we have a cached memoryLimiter with a specific config, // otherwise initialize and add one to the store. -func (f *factory) getMemoryLimiter(set component.ProcessorCreateSettings, cfg component.ProcessorConfig) (*memoryLimiter, error) { +func (f *factory) getMemoryLimiter(set component.ProcessorCreateSettings, cfg component.Config) (*memoryLimiter, error) { f.lock.Lock() defer f.lock.Unlock() diff --git a/processor/processorhelper/logs.go b/processor/processorhelper/logs.go index 67463784d24..984e00b778f 100644 --- a/processor/processorhelper/logs.go +++ b/processor/processorhelper/logs.go @@ -39,7 +39,7 @@ type logProcessor struct { func NewLogsProcessor( _ context.Context, _ component.ProcessorCreateSettings, - cfg component.ProcessorConfig, + cfg component.Config, nextConsumer consumer.Logs, logsFunc ProcessLogsFunc, options ...Option, diff --git a/processor/processorhelper/metrics.go b/processor/processorhelper/metrics.go index 24ec2456f6b..8cf1ee79ecb 100644 --- a/processor/processorhelper/metrics.go +++ b/processor/processorhelper/metrics.go @@ -39,7 +39,7 @@ type metricsProcessor struct { func NewMetricsProcessor( _ context.Context, _ component.ProcessorCreateSettings, - cfg component.ProcessorConfig, + cfg component.Config, nextConsumer consumer.Metrics, metricsFunc ProcessMetricsFunc, options ...Option, diff --git a/processor/processorhelper/traces.go b/processor/processorhelper/traces.go index 8bfbb8864c3..c5fd71666aa 100644 --- a/processor/processorhelper/traces.go +++ b/processor/processorhelper/traces.go @@ -39,7 +39,7 @@ type tracesProcessor struct { func NewTracesProcessor( _ context.Context, _ component.ProcessorCreateSettings, - cfg component.ProcessorConfig, + cfg component.Config, nextConsumer consumer.Traces, tracesFunc ProcessTracesFunc, options ...Option, diff --git a/receiver/otlpreceiver/config.go b/receiver/otlpreceiver/config.go index 06d94aa1e0e..c86701641c0 100644 --- a/receiver/otlpreceiver/config.go +++ b/receiver/otlpreceiver/config.go @@ -43,7 +43,7 @@ type Config struct { Protocols `mapstructure:"protocols"` } -var _ component.ReceiverConfig = (*Config)(nil) +var _ component.Config = (*Config)(nil) var _ confmap.Unmarshaler = (*Config)(nil) // Validate checks the receiver configuration is valid diff --git a/receiver/otlpreceiver/factory.go b/receiver/otlpreceiver/factory.go index 475d700b3d8..53fe53bc0dc 100644 --- a/receiver/otlpreceiver/factory.go +++ b/receiver/otlpreceiver/factory.go @@ -44,7 +44,7 @@ func NewFactory() component.ReceiverFactory { } // createDefaultConfig creates the default configuration for receiver. -func createDefaultConfig() component.ReceiverConfig { +func createDefaultConfig() component.Config { return &Config{ ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)), Protocols: Protocols{ @@ -67,7 +67,7 @@ func createDefaultConfig() component.ReceiverConfig { func createTracesReceiver( _ context.Context, set component.ReceiverCreateSettings, - cfg component.ReceiverConfig, + cfg component.Config, nextConsumer consumer.Traces, ) (component.TracesReceiver, error) { r := receivers.GetOrAdd(cfg, func() component.Component { @@ -84,7 +84,7 @@ func createTracesReceiver( func createMetricsReceiver( _ context.Context, set component.ReceiverCreateSettings, - cfg component.ReceiverConfig, + cfg component.Config, consumer consumer.Metrics, ) (component.MetricsReceiver, error) { r := receivers.GetOrAdd(cfg, func() component.Component { @@ -101,7 +101,7 @@ func createMetricsReceiver( func createLogReceiver( _ context.Context, set component.ReceiverCreateSettings, - cfg component.ReceiverConfig, + cfg component.Config, consumer consumer.Logs, ) (component.LogsReceiver, error) { r := receivers.GetOrAdd(cfg, func() component.Component { diff --git a/service/config.go b/service/config.go index de1fbc2a033..a937dfebb3b 100644 --- a/service/config.go +++ b/service/config.go @@ -32,16 +32,16 @@ var ( // Config defines the configuration for the various elements of collector or agent. type Config struct { // Receivers is a map of ComponentID to Receivers. - Receivers map[component.ID]component.ReceiverConfig + Receivers map[component.ID]component.Config // Exporters is a map of ComponentID to Exporters. - Exporters map[component.ID]component.ExporterConfig + Exporters map[component.ID]component.Config // Processors is a map of ComponentID to Processors. - Processors map[component.ID]component.ProcessorConfig + Processors map[component.ID]component.Config // Extensions is a map of ComponentID to extensions. - Extensions map[component.ID]component.ExtensionConfig + Extensions map[component.ID]component.Config Service ConfigService } diff --git a/service/config_provider_test.go b/service/config_provider_test.go index 2bbfba4568a..70a021cf6a0 100644 --- a/service/config_provider_test.go +++ b/service/config_provider_test.go @@ -34,10 +34,10 @@ import ( ) var configNop = &Config{ - Receivers: map[component.ID]component.ReceiverConfig{component.NewID("nop"): componenttest.NewNopReceiverFactory().CreateDefaultConfig()}, - Processors: map[component.ID]component.ProcessorConfig{component.NewID("nop"): componenttest.NewNopProcessorFactory().CreateDefaultConfig()}, - Exporters: map[component.ID]component.ExporterConfig{component.NewID("nop"): componenttest.NewNopExporterFactory().CreateDefaultConfig()}, - Extensions: map[component.ID]component.ExtensionConfig{component.NewID("nop"): componenttest.NewNopExtensionFactory().CreateDefaultConfig()}, + Receivers: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopReceiverFactory().CreateDefaultConfig()}, + Processors: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopProcessorFactory().CreateDefaultConfig()}, + Exporters: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopExporterFactory().CreateDefaultConfig()}, + Extensions: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopExtensionFactory().CreateDefaultConfig()}, Service: ConfigService{ Extensions: []component.ID{component.NewID("nop")}, Pipelines: map[component.ID]*ConfigServicePipeline{ diff --git a/service/config_test.go b/service/config_test.go index 6719492bb2d..840010b6eef 100644 --- a/service/config_test.go +++ b/service/config_test.go @@ -270,22 +270,22 @@ func TestConfigValidate(t *testing.T) { func generateConfig() *Config { return &Config{ - Receivers: map[component.ID]component.ReceiverConfig{ + Receivers: map[component.ID]component.Config{ component.NewID("nop"): &nopRecvConfig{ ReceiverSettings: config.NewReceiverSettings(component.NewID("nop")), }, }, - Exporters: map[component.ID]component.ExporterConfig{ + Exporters: map[component.ID]component.Config{ component.NewID("nop"): &nopExpConfig{ ExporterSettings: config.NewExporterSettings(component.NewID("nop")), }, }, - Processors: map[component.ID]component.ProcessorConfig{ + Processors: map[component.ID]component.Config{ component.NewID("nop"): &nopProcConfig{ ProcessorSettings: config.NewProcessorSettings(component.NewID("nop")), }, }, - Extensions: map[component.ID]component.ExtensionConfig{ + Extensions: map[component.ID]component.Config{ component.NewID("nop"): &nopExtConfig{ ExtensionSettings: config.NewExtensionSettings(component.NewID("nop")), }, diff --git a/service/extensions/extensions.go b/service/extensions/extensions.go index 8bc1beb0d9b..6d8d662eef9 100644 --- a/service/extensions/extensions.go +++ b/service/extensions/extensions.go @@ -122,8 +122,8 @@ type Settings struct { Telemetry component.TelemetrySettings BuildInfo component.BuildInfo - // Configs is a map of component.ID to component.ExtensionConfig. - Configs map[component.ID]component.ExtensionConfig + // Configs is a map of component.ID to component.Config. + Configs map[component.ID]component.Config // Factories maps extension type names in the config to the respective component.ExtensionFactory. Factories map[component.Type]component.ExtensionFactory diff --git a/service/extensions/extensions_test.go b/service/extensions/extensions_test.go index 3eb33d15fe6..cf7873c697b 100644 --- a/service/extensions/extensions_test.go +++ b/service/extensions/extensions_test.go @@ -38,7 +38,7 @@ func TestBuildExtensions(t *testing.T) { tests := []struct { name string factories component.Factories - extensionsConfigs map[component.ID]component.ExtensionConfig + extensionsConfigs map[component.ID]component.Config serviceExtensions []component.ID wantErrMsg string }{ @@ -51,7 +51,7 @@ func TestBuildExtensions(t *testing.T) { }, { name: "missing_extension_factory", - extensionsConfigs: map[component.ID]component.ExtensionConfig{ + extensionsConfigs: map[component.ID]component.Config{ component.NewID("unknown"): nopExtensionConfig, }, serviceExtensions: []component.ID{ @@ -66,7 +66,7 @@ func TestBuildExtensions(t *testing.T) { errExtensionFactory.Type(): errExtensionFactory, }, }, - extensionsConfigs: map[component.ID]component.ExtensionConfig{ + extensionsConfigs: map[component.ID]component.Config{ component.NewID(errExtensionFactory.Type()): errExtensionConfig, }, serviceExtensions: []component.ID{ @@ -81,7 +81,7 @@ func TestBuildExtensions(t *testing.T) { badExtensionFactory.Type(): badExtensionFactory, }, }, - extensionsConfigs: map[component.ID]component.ExtensionConfig{ + extensionsConfigs: map[component.ID]component.Config{ component.NewID(badExtensionFactory.Type()): badExtensionCfg, }, serviceExtensions: []component.ID{ @@ -108,14 +108,14 @@ func TestBuildExtensions(t *testing.T) { func newBadExtensionFactory() component.ExtensionFactory { return component.NewExtensionFactory( "bf", - func() component.ExtensionConfig { + func() component.Config { return &struct { config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct }{ ExtensionSettings: config.NewExtensionSettings(component.NewID("bf")), } }, - func(ctx context.Context, set component.ExtensionCreateSettings, extension component.ExtensionConfig) (component.Extension, error) { + func(ctx context.Context, set component.ExtensionCreateSettings, extension component.Config) (component.Extension, error) { return nil, nil }, component.StabilityLevelDevelopment, @@ -125,14 +125,14 @@ func newBadExtensionFactory() component.ExtensionFactory { func newCreateErrorExtensionFactory() component.ExtensionFactory { return component.NewExtensionFactory( "err", - func() component.ExtensionConfig { + func() component.Config { return &struct { config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct }{ ExtensionSettings: config.NewExtensionSettings(component.NewID("err")), } }, - func(ctx context.Context, set component.ExtensionCreateSettings, extension component.ExtensionConfig) (component.Extension, error) { + func(ctx context.Context, set component.ExtensionCreateSettings, extension component.Config) (component.Extension, error) { return nil, errors.New("cannot create \"err\" extension type") }, component.StabilityLevelDevelopment, diff --git a/service/internal/configunmarshaler/exporters.go b/service/internal/configunmarshaler/exporters.go index c3a69a1d105..898eb7f849b 100644 --- a/service/internal/configunmarshaler/exporters.go +++ b/service/internal/configunmarshaler/exporters.go @@ -25,7 +25,7 @@ import ( const exportersKeyName = "exporters" type Exporters struct { - exps map[component.ID]component.ExporterConfig + exps map[component.ID]component.Config factories map[component.Type]component.ExporterFactory } @@ -41,7 +41,7 @@ func (e *Exporters) Unmarshal(conf *confmap.Conf) error { } // Prepare resulting map. - e.exps = make(map[component.ID]component.ExporterConfig) + e.exps = make(map[component.ID]component.Config) // Iterate over Exporters and create a config for each. for id, value := range rawExps { @@ -67,6 +67,6 @@ func (e *Exporters) Unmarshal(conf *confmap.Conf) error { return nil } -func (e *Exporters) GetExporters() map[component.ID]component.ExporterConfig { +func (e *Exporters) GetExporters() map[component.ID]component.Config { return e.exps } diff --git a/service/internal/configunmarshaler/exporters_test.go b/service/internal/configunmarshaler/exporters_test.go index 5f8ba6caad5..59e37c21b6d 100644 --- a/service/internal/configunmarshaler/exporters_test.go +++ b/service/internal/configunmarshaler/exporters_test.go @@ -38,7 +38,7 @@ func TestExportersUnmarshal(t *testing.T) { cfgWithName := factories.Exporters["nop"].CreateDefaultConfig() cfgWithName.SetIDName("myexporter") - assert.Equal(t, map[component.ID]component.ExporterConfig{ + assert.Equal(t, map[component.ID]component.Config{ component.NewID("nop"): factories.Exporters["nop"].CreateDefaultConfig(), component.NewIDWithName("nop", "myexporter"): cfgWithName, }, exps.GetExporters()) diff --git a/service/internal/configunmarshaler/extensions.go b/service/internal/configunmarshaler/extensions.go index b44024c1361..f986b85de6a 100644 --- a/service/internal/configunmarshaler/extensions.go +++ b/service/internal/configunmarshaler/extensions.go @@ -25,7 +25,7 @@ import ( const extensionsKeyName = "extensions" type Extensions struct { - exts map[component.ID]component.ExtensionConfig + exts map[component.ID]component.Config factories map[component.Type]component.ExtensionFactory } @@ -41,7 +41,7 @@ func (e *Extensions) Unmarshal(conf *confmap.Conf) error { } // Prepare resulting map. - e.exts = make(map[component.ID]component.ExtensionConfig) + e.exts = make(map[component.ID]component.Config) // Iterate over extensions and create a config for each. for id, value := range rawExts { @@ -67,6 +67,6 @@ func (e *Extensions) Unmarshal(conf *confmap.Conf) error { return nil } -func (e *Extensions) GetExtensions() map[component.ID]component.ExtensionConfig { +func (e *Extensions) GetExtensions() map[component.ID]component.Config { return e.exts } diff --git a/service/internal/configunmarshaler/extensions_test.go b/service/internal/configunmarshaler/extensions_test.go index 3f6a7e57eee..bc7f38a760a 100644 --- a/service/internal/configunmarshaler/extensions_test.go +++ b/service/internal/configunmarshaler/extensions_test.go @@ -38,7 +38,7 @@ func TestExtensionsUnmarshal(t *testing.T) { cfgWithName := factories.Extensions["nop"].CreateDefaultConfig() cfgWithName.SetIDName("myextension") - assert.Equal(t, map[component.ID]component.ExtensionConfig{ + assert.Equal(t, map[component.ID]component.Config{ component.NewID("nop"): factories.Extensions["nop"].CreateDefaultConfig(), component.NewIDWithName("nop", "myextension"): cfgWithName, }, exts.GetExtensions()) diff --git a/service/internal/configunmarshaler/processors.go b/service/internal/configunmarshaler/processors.go index a5d8e21d011..7a51720d037 100644 --- a/service/internal/configunmarshaler/processors.go +++ b/service/internal/configunmarshaler/processors.go @@ -25,7 +25,7 @@ import ( const processorsKeyName = "processors" type Processors struct { - procs map[component.ID]component.ProcessorConfig + procs map[component.ID]component.Config factories map[component.Type]component.ProcessorFactory } @@ -41,7 +41,7 @@ func (p *Processors) Unmarshal(conf *confmap.Conf) error { } // Prepare resulting map. - p.procs = make(map[component.ID]component.ProcessorConfig) + p.procs = make(map[component.ID]component.Config) // Iterate over processors and create a config for each. for id, value := range rawProcs { // Find processor factory based on "type" that we read from config source. @@ -66,6 +66,6 @@ func (p *Processors) Unmarshal(conf *confmap.Conf) error { return nil } -func (p *Processors) GetProcessors() map[component.ID]component.ProcessorConfig { +func (p *Processors) GetProcessors() map[component.ID]component.Config { return p.procs } diff --git a/service/internal/configunmarshaler/processors_test.go b/service/internal/configunmarshaler/processors_test.go index 58583251053..702f39220d3 100644 --- a/service/internal/configunmarshaler/processors_test.go +++ b/service/internal/configunmarshaler/processors_test.go @@ -38,7 +38,7 @@ func TestProcessorsUnmarshal(t *testing.T) { cfgWithName := factories.Processors["nop"].CreateDefaultConfig() cfgWithName.SetIDName("myprocessor") - assert.Equal(t, map[component.ID]component.ProcessorConfig{ + assert.Equal(t, map[component.ID]component.Config{ component.NewID("nop"): factories.Processors["nop"].CreateDefaultConfig(), component.NewIDWithName("nop", "myprocessor"): cfgWithName, }, procs.procs) diff --git a/service/internal/configunmarshaler/receivers.go b/service/internal/configunmarshaler/receivers.go index 36934dc4c23..8f46573f174 100644 --- a/service/internal/configunmarshaler/receivers.go +++ b/service/internal/configunmarshaler/receivers.go @@ -25,7 +25,7 @@ import ( const receiversKeyName = "receivers" type Receivers struct { - recvs map[component.ID]component.ReceiverConfig + recvs map[component.ID]component.Config factories map[component.Type]component.ReceiverFactory } @@ -41,7 +41,7 @@ func (r *Receivers) Unmarshal(conf *confmap.Conf) error { } // Prepare resulting map. - r.recvs = make(map[component.ID]component.ReceiverConfig) + r.recvs = make(map[component.ID]component.Config) // Iterate over input map and create a config for each. for id, value := range rawRecvs { @@ -67,6 +67,6 @@ func (r *Receivers) Unmarshal(conf *confmap.Conf) error { return nil } -func (r *Receivers) GetReceivers() map[component.ID]component.ReceiverConfig { +func (r *Receivers) GetReceivers() map[component.ID]component.Config { return r.recvs } diff --git a/service/internal/configunmarshaler/receivers_test.go b/service/internal/configunmarshaler/receivers_test.go index 41255118ba4..f3aa6ce7665 100644 --- a/service/internal/configunmarshaler/receivers_test.go +++ b/service/internal/configunmarshaler/receivers_test.go @@ -38,7 +38,7 @@ func TestReceiversUnmarshal(t *testing.T) { cfgWithName := factories.Receivers["nop"].CreateDefaultConfig() cfgWithName.SetIDName("myreceiver") - assert.Equal(t, map[component.ID]component.ReceiverConfig{ + assert.Equal(t, map[component.ID]component.Config{ component.NewID("nop"): factories.Receivers["nop"].CreateDefaultConfig(), component.NewIDWithName("nop", "myreceiver"): cfgWithName, }, recvs.GetReceivers()) diff --git a/service/internal/pipelines/pipelines.go b/service/internal/pipelines/pipelines.go index 726ca95e6fa..9b4e2579021 100644 --- a/service/internal/pipelines/pipelines.go +++ b/service/internal/pipelines/pipelines.go @@ -185,20 +185,20 @@ type Settings struct { // ReceiverFactories maps receiver type names in the config to the respective component.ReceiverFactory. ReceiverFactories map[component.Type]component.ReceiverFactory - // ReceiverConfigs is a map of component.ID to component.ReceiverConfig. - ReceiverConfigs map[component.ID]component.ReceiverConfig + // ReceiverConfigs is a map of component.ID to component.Config. + ReceiverConfigs map[component.ID]component.Config // ProcessorFactories maps processor type names in the config to the respective component.ProcessorFactory. ProcessorFactories map[component.Type]component.ProcessorFactory - // ProcessorConfigs is a map of component.ID to component.ProcessorConfig. - ProcessorConfigs map[component.ID]component.ProcessorConfig + // ProcessorConfigs is a map of component.ID to component.Config. + ProcessorConfigs map[component.ID]component.Config // ExporterFactories maps exporter type names in the config to the respective component.ExporterFactory. ExporterFactories map[component.Type]component.ExporterFactory - // ExporterConfigs is a map of component.ID to component.ExporterConfig. - ExporterConfigs map[component.ID]component.ExporterConfig + // ExporterConfigs is a map of component.ID to component.Config. + ExporterConfigs map[component.ID]component.Config // PipelineConfigs is a map of component.ID to config.Pipeline. PipelineConfigs map[component.ID]*config.Pipeline @@ -335,7 +335,7 @@ func buildExporter( ctx context.Context, settings component.TelemetrySettings, buildInfo component.BuildInfo, - cfgs map[component.ID]component.ExporterConfig, + cfgs map[component.ID]component.Config, factories map[component.Type]component.ExporterFactory, id component.ID, pipelineID component.ID, @@ -365,7 +365,7 @@ func buildExporter( return exp, nil } -func createExporter(ctx context.Context, set component.ExporterCreateSettings, cfg component.ExporterConfig, id component.ID, pipelineID component.ID, factory component.ExporterFactory) (component.Component, error) { +func createExporter(ctx context.Context, set component.ExporterCreateSettings, cfg component.Config, id component.ID, pipelineID component.ID, factory component.ExporterFactory) (component.Component, error) { switch pipelineID.Type() { case component.DataTypeTraces: return factory.CreateTracesExporter(ctx, set, cfg) @@ -428,7 +428,7 @@ func getExporterStabilityLevel(factory component.ExporterFactory, dt component.D func buildProcessor(ctx context.Context, settings component.TelemetrySettings, buildInfo component.BuildInfo, - cfgs map[component.ID]component.ProcessorConfig, + cfgs map[component.ID]component.Config, factories map[component.Type]component.ProcessorFactory, id component.ID, pipelineID component.ID, @@ -458,7 +458,7 @@ func buildProcessor(ctx context.Context, return proc, nil } -func createProcessor(ctx context.Context, set component.ProcessorCreateSettings, cfg component.ProcessorConfig, id component.ID, pipelineID component.ID, next baseConsumer, factory component.ProcessorFactory) (component.Component, error) { +func createProcessor(ctx context.Context, set component.ProcessorCreateSettings, cfg component.Config, id component.ID, pipelineID component.ID, next baseConsumer, factory component.ProcessorFactory) (component.Component, error) { switch pipelineID.Type() { case component.DataTypeTraces: return factory.CreateTracesProcessor(ctx, set, cfg, next.(consumer.Traces)) @@ -494,7 +494,7 @@ func getProcessorStabilityLevel(factory component.ProcessorFactory, dt component func buildReceiver(ctx context.Context, settings component.TelemetrySettings, buildInfo component.BuildInfo, - cfgs map[component.ID]component.ReceiverConfig, + cfgs map[component.ID]component.Config, factories map[component.Type]component.ReceiverFactory, id component.ID, pipelineID component.ID, @@ -525,7 +525,7 @@ func buildReceiver(ctx context.Context, return recv, nil } -func createReceiver(ctx context.Context, set component.ReceiverCreateSettings, cfg component.ReceiverConfig, id component.ID, pipelineID component.ID, nexts []baseConsumer, factory component.ReceiverFactory) (component.Component, error) { +func createReceiver(ctx context.Context, set component.ReceiverCreateSettings, cfg component.Config, id component.ID, pipelineID component.ID, nexts []baseConsumer, factory component.ReceiverFactory) (component.Component, error) { switch pipelineID.Type() { case component.DataTypeTraces: var consumers []consumer.Traces diff --git a/service/internal/pipelines/pipelines_test.go b/service/internal/pipelines/pipelines_test.go index 2802d68dbf5..fd6ac871d00 100644 --- a/service/internal/pipelines/pipelines_test.go +++ b/service/internal/pipelines/pipelines_test.go @@ -278,7 +278,7 @@ func TestFailToStartAndShutdown(t *testing.T) { nopReceiverFactory.Type(): nopReceiverFactory, errReceiverFactory.Type(): errReceiverFactory, }, - ReceiverConfigs: map[component.ID]component.ReceiverConfig{ + ReceiverConfigs: map[component.ID]component.Config{ component.NewID(nopReceiverFactory.Type()): nopReceiverFactory.CreateDefaultConfig(), component.NewID(errReceiverFactory.Type()): errReceiverFactory.CreateDefaultConfig(), }, @@ -286,7 +286,7 @@ func TestFailToStartAndShutdown(t *testing.T) { nopProcessorFactory.Type(): nopProcessorFactory, errProcessorFactory.Type(): errProcessorFactory, }, - ProcessorConfigs: map[component.ID]component.ProcessorConfig{ + ProcessorConfigs: map[component.ID]component.Config{ component.NewID(nopProcessorFactory.Type()): nopProcessorFactory.CreateDefaultConfig(), component.NewID(errProcessorFactory.Type()): errProcessorFactory.CreateDefaultConfig(), }, @@ -294,7 +294,7 @@ func TestFailToStartAndShutdown(t *testing.T) { nopExporterFactory.Type(): nopExporterFactory, errExporterFactory.Type(): errExporterFactory, }, - ExporterConfigs: map[component.ID]component.ExporterConfig{ + ExporterConfigs: map[component.ID]component.Config{ component.NewID(nopExporterFactory.Type()): nopExporterFactory.CreateDefaultConfig(), component.NewID(errExporterFactory.Type()): errExporterFactory.CreateDefaultConfig(), }, @@ -346,7 +346,7 @@ func TestFailToStartAndShutdown(t *testing.T) { } func newBadReceiverFactory() component.ReceiverFactory { - return component.NewReceiverFactory("bf", func() component.ReceiverConfig { + return component.NewReceiverFactory("bf", func() component.Config { return &struct { config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct }{ @@ -356,7 +356,7 @@ func newBadReceiverFactory() component.ReceiverFactory { } func newBadProcessorFactory() component.ProcessorFactory { - return component.NewProcessorFactory("bf", func() component.ProcessorConfig { + return component.NewProcessorFactory("bf", func() component.Config { return &struct { config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct }{ @@ -366,7 +366,7 @@ func newBadProcessorFactory() component.ProcessorFactory { } func newBadExporterFactory() component.ExporterFactory { - return component.NewExporterFactory("bf", func() component.ExporterConfig { + return component.NewExporterFactory("bf", func() component.Config { return &struct { config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct }{ @@ -376,60 +376,60 @@ func newBadExporterFactory() component.ExporterFactory { } func newErrReceiverFactory() component.ReceiverFactory { - return component.NewReceiverFactory("err", func() component.ReceiverConfig { + return component.NewReceiverFactory("err", func() component.Config { return &struct { config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct }{ ReceiverSettings: config.NewReceiverSettings(component.NewID("bf")), } }, - component.WithTracesReceiver(func(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Traces) (component.TracesReceiver, error) { + component.WithTracesReceiver(func(context.Context, component.ReceiverCreateSettings, component.Config, consumer.Traces) (component.TracesReceiver, error) { return &errComponent{}, nil }, component.StabilityLevelUndefined), - component.WithLogsReceiver(func(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Logs) (component.LogsReceiver, error) { + component.WithLogsReceiver(func(context.Context, component.ReceiverCreateSettings, component.Config, consumer.Logs) (component.LogsReceiver, error) { return &errComponent{}, nil }, component.StabilityLevelUndefined), - component.WithMetricsReceiver(func(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Metrics) (component.MetricsReceiver, error) { + component.WithMetricsReceiver(func(context.Context, component.ReceiverCreateSettings, component.Config, consumer.Metrics) (component.MetricsReceiver, error) { return &errComponent{}, nil }, component.StabilityLevelUndefined), ) } func newErrProcessorFactory() component.ProcessorFactory { - return component.NewProcessorFactory("err", func() component.ProcessorConfig { + return component.NewProcessorFactory("err", func() component.Config { return &struct { config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct }{ ProcessorSettings: config.NewProcessorSettings(component.NewID("bf")), } }, - component.WithTracesProcessor(func(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Traces) (component.TracesProcessor, error) { + component.WithTracesProcessor(func(context.Context, component.ProcessorCreateSettings, component.Config, consumer.Traces) (component.TracesProcessor, error) { return &errComponent{}, nil }, component.StabilityLevelUndefined), - component.WithLogsProcessor(func(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Logs) (component.LogsProcessor, error) { + component.WithLogsProcessor(func(context.Context, component.ProcessorCreateSettings, component.Config, consumer.Logs) (component.LogsProcessor, error) { return &errComponent{}, nil }, component.StabilityLevelUndefined), - component.WithMetricsProcessor(func(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Metrics) (component.MetricsProcessor, error) { + component.WithMetricsProcessor(func(context.Context, component.ProcessorCreateSettings, component.Config, consumer.Metrics) (component.MetricsProcessor, error) { return &errComponent{}, nil }, component.StabilityLevelUndefined), ) } func newErrExporterFactory() component.ExporterFactory { - return component.NewExporterFactory("err", func() component.ExporterConfig { + return component.NewExporterFactory("err", func() component.Config { return &struct { config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct }{ ExporterSettings: config.NewExporterSettings(component.NewID("bf")), } }, - component.WithTracesExporter(func(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.TracesExporter, error) { + component.WithTracesExporter(func(context.Context, component.ExporterCreateSettings, component.Config) (component.TracesExporter, error) { return &errComponent{}, nil }, component.StabilityLevelUndefined), - component.WithLogsExporter(func(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.LogsExporter, error) { + component.WithLogsExporter(func(context.Context, component.ExporterCreateSettings, component.Config) (component.LogsExporter, error) { return &errComponent{}, nil }, component.StabilityLevelUndefined), - component.WithMetricsExporter(func(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.MetricsExporter, error) { + component.WithMetricsExporter(func(context.Context, component.ExporterCreateSettings, component.Config) (component.MetricsExporter, error) { return &errComponent{}, nil }, component.StabilityLevelUndefined), ) diff --git a/service/internal/testcomponents/example_exporter.go b/service/internal/testcomponents/example_exporter.go index bc680b79acf..fe91a5e2fdb 100644 --- a/service/internal/testcomponents/example_exporter.go +++ b/service/internal/testcomponents/example_exporter.go @@ -44,21 +44,21 @@ var ExampleExporterFactory = component.NewExporterFactory( component.WithLogsExporter(createLogsExporter, stability), ) -func createExporterDefaultConfig() component.ExporterConfig { +func createExporterDefaultConfig() component.Config { return &ExampleExporterConfig{ ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)), } } -func createTracesExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.TracesExporter, error) { +func createTracesExporter(context.Context, component.ExporterCreateSettings, component.Config) (component.TracesExporter, error) { return &ExampleExporter{}, nil } -func createMetricsExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.MetricsExporter, error) { +func createMetricsExporter(context.Context, component.ExporterCreateSettings, component.Config) (component.MetricsExporter, error) { return &ExampleExporter{}, nil } -func createLogsExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.LogsExporter, error) { +func createLogsExporter(context.Context, component.ExporterCreateSettings, component.Config) (component.LogsExporter, error) { return &ExampleExporter{}, nil } diff --git a/service/internal/testcomponents/example_processor.go b/service/internal/testcomponents/example_processor.go index e7e573c8cf8..092a6acabe3 100644 --- a/service/internal/testcomponents/example_processor.go +++ b/service/internal/testcomponents/example_processor.go @@ -38,21 +38,21 @@ var ExampleProcessorFactory = component.NewProcessorFactory( component.WithLogsProcessor(createLogsProcessor, component.StabilityLevelDevelopment)) // CreateDefaultConfig creates the default configuration for the Processor. -func createDefaultConfig() component.ProcessorConfig { +func createDefaultConfig() component.Config { return &ExampleProcessorConfig{ ProcessorSettings: config.NewProcessorSettings(component.NewID(procType)), } } -func createTracesProcessor(_ context.Context, _ component.ProcessorCreateSettings, _ component.ProcessorConfig, nextConsumer consumer.Traces) (component.TracesProcessor, error) { +func createTracesProcessor(_ context.Context, _ component.ProcessorCreateSettings, _ component.Config, nextConsumer consumer.Traces) (component.TracesProcessor, error) { return &ExampleProcessor{Traces: nextConsumer}, nil } -func createMetricsProcessor(_ context.Context, _ component.ProcessorCreateSettings, _ component.ProcessorConfig, nextConsumer consumer.Metrics) (component.MetricsProcessor, error) { +func createMetricsProcessor(_ context.Context, _ component.ProcessorCreateSettings, _ component.Config, nextConsumer consumer.Metrics) (component.MetricsProcessor, error) { return &ExampleProcessor{Metrics: nextConsumer}, nil } -func createLogsProcessor(_ context.Context, _ component.ProcessorCreateSettings, _ component.ProcessorConfig, nextConsumer consumer.Logs) (component.LogsProcessor, error) { +func createLogsProcessor(_ context.Context, _ component.ProcessorCreateSettings, _ component.Config, nextConsumer consumer.Logs) (component.LogsProcessor, error) { return &ExampleProcessor{Logs: nextConsumer}, nil } diff --git a/service/internal/testcomponents/example_receiver.go b/service/internal/testcomponents/example_receiver.go index dfe0a1ce2f9..f69ec2c0f1e 100644 --- a/service/internal/testcomponents/example_receiver.go +++ b/service/internal/testcomponents/example_receiver.go @@ -37,7 +37,7 @@ var ExampleReceiverFactory = component.NewReceiverFactory( component.WithMetricsReceiver(createMetricsReceiver, component.StabilityLevelDevelopment), component.WithLogsReceiver(createLogsReceiver, component.StabilityLevelDevelopment)) -func createReceiverDefaultConfig() component.ReceiverConfig { +func createReceiverDefaultConfig() component.Config { return &ExampleReceiverConfig{ ReceiverSettings: config.NewReceiverSettings(component.NewID(receiverType)), } @@ -47,7 +47,7 @@ func createReceiverDefaultConfig() component.ReceiverConfig { func createTracesReceiver( _ context.Context, _ component.ReceiverCreateSettings, - cfg component.ReceiverConfig, + cfg component.Config, nextConsumer consumer.Traces, ) (component.TracesReceiver, error) { receiver := createReceiver(cfg) @@ -59,7 +59,7 @@ func createTracesReceiver( func createMetricsReceiver( _ context.Context, _ component.ReceiverCreateSettings, - cfg component.ReceiverConfig, + cfg component.Config, nextConsumer consumer.Metrics, ) (component.MetricsReceiver, error) { receiver := createReceiver(cfg) @@ -70,7 +70,7 @@ func createMetricsReceiver( func createLogsReceiver( _ context.Context, _ component.ReceiverCreateSettings, - cfg component.ReceiverConfig, + cfg component.Config, nextConsumer consumer.Logs, ) (component.LogsReceiver, error) { receiver := createReceiver(cfg) @@ -78,7 +78,7 @@ func createLogsReceiver( return receiver, nil } -func createReceiver(cfg component.ReceiverConfig) *ExampleReceiver { +func createReceiver(cfg component.Config) *ExampleReceiver { // There must be one receiver for all data types. We maintain a map of // receivers per config. @@ -118,4 +118,4 @@ func (erp *ExampleReceiver) Shutdown(context.Context) error { // We maintain this map because the ReceiverFactory is asked trace and metric receivers separately // when it gets CreateTracesReceiver() and CreateMetricsReceiver() but they must not // create separate objects, they must use one Receiver object per configuration. -var exampleReceivers = map[component.ReceiverConfig]*ExampleReceiver{} +var exampleReceivers = map[component.Config]*ExampleReceiver{}