Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Fix small nits in profiles factories #11325

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions connector/connectorprofiles/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
})
}

Expand Down Expand Up @@ -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
}
17 changes: 4 additions & 13 deletions exporter/exporterprofiles/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
17 changes: 4 additions & 13 deletions processor/processorprofiles/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
18 changes: 5 additions & 13 deletions receiver/receiverprofiles/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

}
Loading