diff --git a/connector/connectorprofiles/connector.go b/connector/connectorprofiles/connector.go index 8fb6167e1e4..6c2f3d7d7bf 100644 --- a/connector/connectorprofiles/connector.go +++ b/connector/connectorprofiles/connector.go @@ -147,7 +147,7 @@ func (f factoryOptionFunc) applyOption(o *factoryOpts) { type factoryOpts struct { opts []connector.FactoryOption - factory *factory + *factory } // WithTracesToTraces overrides the default "error not supported" implementation for WithTracesToTraces and the default "undefined" stability level. @@ -216,56 +216,56 @@ func WithLogsToLogs(createLogsToLogs connector.CreateLogsToLogsFunc, sl componen // WithTracesToProfiles overrides the default "error not supported" implementation for WithTracesToProfiles and the default "undefined" stability level. func WithTracesToProfiles(createTracesToProfiles CreateTracesToProfilesFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.factory.tracesToProfilesStabilityLevel = sl - o.factory.CreateTracesToProfilesFunc = createTracesToProfiles + o.tracesToProfilesStabilityLevel = sl + o.CreateTracesToProfilesFunc = createTracesToProfiles }) } // WithMetricsToProfiles overrides the default "error not supported" implementation for WithMetricsToProfiles and the default "undefined" stability level. func WithMetricsToProfiles(createMetricsToProfiles CreateMetricsToProfilesFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.factory.metricsToProfilesStabilityLevel = sl - o.factory.CreateMetricsToProfilesFunc = createMetricsToProfiles + o.metricsToProfilesStabilityLevel = sl + o.CreateMetricsToProfilesFunc = createMetricsToProfiles }) } // WithLogsToProfiles overrides the default "error not supported" implementation for WithLogsToProfiles and the default "undefined" stability level. func WithLogsToProfiles(createLogsToProfiles CreateLogsToProfilesFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.factory.logsToProfilesStabilityLevel = sl - o.factory.CreateLogsToProfilesFunc = createLogsToProfiles + o.logsToProfilesStabilityLevel = sl + o.CreateLogsToProfilesFunc = createLogsToProfiles }) } // WithProfilesToProfiles overrides the default "error not supported" implementation for WithProfilesToProfiles and the default "undefined" stability level. func WithProfilesToProfiles(createProfilesToProfiles CreateProfilesToProfilesFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.factory.profilesToProfilesStabilityLevel = sl - o.factory.CreateProfilesToProfilesFunc = createProfilesToProfiles + o.profilesToProfilesStabilityLevel = sl + o.CreateProfilesToProfilesFunc = createProfilesToProfiles }) } // WithProfilesToTraces overrides the default "error not supported" implementation for WithProfilesToTraces and the default "undefined" stability level. func WithProfilesToTraces(createProfilesToTraces CreateProfilesToTracesFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.factory.profilesToTracesStabilityLevel = sl - o.factory.CreateProfilesToTracesFunc = createProfilesToTraces + o.profilesToTracesStabilityLevel = sl + o.CreateProfilesToTracesFunc = createProfilesToTraces }) } // WithProfilesToMetrics overrides the default "error not supported" implementation for WithProfilesToMetrics and the default "undefined" stability level. func WithProfilesToMetrics(createProfilesToMetrics CreateProfilesToMetricsFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.factory.profilesToMetricsStabilityLevel = sl - o.factory.CreateProfilesToMetricsFunc = createProfilesToMetrics + o.profilesToMetricsStabilityLevel = sl + o.CreateProfilesToMetricsFunc = createProfilesToMetrics }) } // WithProfilesToLogs overrides the default "error not supported" implementation for WithProfilesToLogs and the default "undefined" stability level. func WithProfilesToLogs(createProfilesToLogs CreateProfilesToLogsFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.factory.profilesToLogsStabilityLevel = sl - o.factory.CreateProfilesToLogsFunc = createProfilesToLogs + o.profilesToLogsStabilityLevel = sl + o.CreateProfilesToLogsFunc = createProfilesToLogs }) } @@ -322,12 +322,10 @@ func (f *factory) ProfilesToLogsStability() component.StabilityLevel { // NewFactory returns a Factory. func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefaultConfigFunc, options ...FactoryOption) Factory { - opts := factoryOpts{ - factory: &factory{}, - } + opts := factoryOpts{factory: &factory{}} for _, opt := range options { opt.applyOption(&opts) } - opts.factory.Factory = connector.NewFactory(cfgType, createDefaultConfig, opts.opts...) + opts.Factory = connector.NewFactory(cfgType, createDefaultConfig, opts.opts...) return opts.factory } diff --git a/exporter/exporterprofiles/exporter.go b/exporter/exporterprofiles/exporter.go index 56b09574a91..7d2801d071f 100644 --- a/exporter/exporterprofiles/exporter.go +++ b/exporter/exporterprofiles/exporter.go @@ -44,11 +44,8 @@ func (f factoryOptionFunc) applyOption(o *factoryOpts) { } type factoryOpts struct { - cfgType component.Type - component.CreateDefaultConfigFunc opts []exporter.FactoryOption - CreateProfilesFunc - profilesStabilityLevel component.StabilityLevel + *factory } // CreateProfilesFunc is the equivalent of Factory.CreateProfiles. @@ -103,16 +100,10 @@ func (f *factory) ProfilesExporterStability() component.StabilityLevel { // NewFactory returns a Factory. func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefaultConfigFunc, options ...FactoryOption) Factory { - opts := factoryOpts{ - cfgType: cfgType, - CreateDefaultConfigFunc: createDefaultConfig, - } + opts := factoryOpts{factory: &factory{}} for _, opt := range options { opt.applyOption(&opts) } - return &factory{ - Factory: exporter.NewFactory(opts.cfgType, opts.CreateDefaultConfig, opts.opts...), - CreateProfilesFunc: opts.CreateProfilesFunc, - profilesStabilityLevel: opts.profilesStabilityLevel, - } + opts.factory.Factory = exporter.NewFactory(cfgType, createDefaultConfig, opts.opts...) + return opts.factory } diff --git a/processor/processorprofiles/processor.go b/processor/processorprofiles/processor.go index 6ccacad7bc6..a79147c4d95 100644 --- a/processor/processorprofiles/processor.go +++ b/processor/processorprofiles/processor.go @@ -78,11 +78,8 @@ func (f factory) ProfilesStability() component.StabilityLevel { } type factoryOpts struct { - cfgType component.Type - component.CreateDefaultConfigFunc opts []processor.FactoryOption - CreateProfilesFunc - profilesStabilityLevel component.StabilityLevel + *factory } // WithTraces overrides the default "error not supported" implementation for CreateTraces and the default "undefined" stability level. @@ -116,16 +113,10 @@ func WithProfiles(createProfiles CreateProfilesFunc, sl component.StabilityLevel // NewFactory returns a Factory. func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefaultConfigFunc, options ...FactoryOption) Factory { - opts := factoryOpts{ - cfgType: cfgType, - CreateDefaultConfigFunc: createDefaultConfig, - } + opts := factoryOpts{factory: &factory{}} for _, opt := range options { opt.applyOption(&opts) } - return &factory{ - Factory: processor.NewFactory(opts.cfgType, opts.CreateDefaultConfig, opts.opts...), - CreateProfilesFunc: opts.CreateProfilesFunc, - profilesStabilityLevel: opts.profilesStabilityLevel, - } + opts.factory.Factory = processor.NewFactory(cfgType, createDefaultConfig, opts.opts...) + return opts.factory } diff --git a/receiver/receiverprofiles/profiles.go b/receiver/receiverprofiles/profiles.go index dea184810a9..d1d2d9dc281 100644 --- a/receiver/receiverprofiles/profiles.go +++ b/receiver/receiverprofiles/profiles.go @@ -88,11 +88,8 @@ func (f *factory) ProfilesReceiverStability() component.StabilityLevel { } type factoryOpts struct { - cfgType component.Type - component.CreateDefaultConfigFunc opts []receiver.FactoryOption - CreateProfilesFunc - profilesStabilityLevel component.StabilityLevel + *factory } // WithTraces overrides the default "error not supported" implementation for Factory.CreateTraces and the default "undefined" stability level. @@ -126,16 +123,11 @@ func WithProfiles(createProfiles CreateProfilesFunc, sl component.StabilityLevel // NewFactory returns a Factory. func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefaultConfigFunc, options ...FactoryOption) Factory { - opts := factoryOpts{ - cfgType: cfgType, - CreateDefaultConfigFunc: createDefaultConfig, - } + opts := factoryOpts{factory: &factory{}} for _, opt := range options { opt.applyOption(&opts) } - return &factory{ - Factory: receiver.NewFactory(opts.cfgType, opts.CreateDefaultConfig, opts.opts...), - CreateProfilesFunc: opts.CreateProfilesFunc, - profilesStabilityLevel: opts.profilesStabilityLevel, - } + opts.factory.Factory = receiver.NewFactory(cfgType, createDefaultConfig, opts.opts...) + return opts.factory + }