Skip to content

Commit

Permalink
Remove deprecated funcs from component (#5917)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan <[email protected]>

Signed-off-by: Bogdan <[email protected]>
  • Loading branch information
bogdandrutu authored Aug 16, 2022
1 parent f6d15f6 commit fdf4885
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 53 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

- Remove deprecated settings from `obsreport`, `ProcessorSettings.Level` and `ExporterSettings.Level` (#5918)
- Replace `processorhelper.New[Traces|Metrics|Logs]Exporter` with `processorhelper.New[Traces|Metrics|Logs]ProcessorWithCreateSettings` definition (#5915)

- Replace `exporterhelper.New[Traces|Metrics|Logs]Exporter` with `exporterhelper.New[Traces|Metrics|Logs]ExporterWithContext` definition (#5914)
- Replace ``component.NewExtensionFactory`` with `component.NewExtensionFactoryWithStabilityLevel` definition (#5917)

### 🚩 Deprecations 🚩

- Deprecate `processorhelper.New[Traces|Metrics|Logs]ProcessorWithCreateSettings` in favor of `processorhelper.New[Traces|Metrics|Logs]Exporter` (#5915)
- Deprecates `LogRecord.Flags()` and `LogRecord.SetFlags()` in favor of `LogRecord.FlagsStruct()`. (#5866)
- Deprecate `exporterhelper.New[Traces|Metrics|Logs]ExporterWithContext` in favor of `exporterhelper.New[Traces|Metrics|Logs]Exporter` (#5914)
- Deprecate `component.NewExtensionFactoryWithStabilityLevel` in favor of `component.NewExtensionFactory` (#5917)

### 💡 Enhancements 💡
- Add support to unmarshalls bytes into pmetric.Metrics with `jsoniter` in jsonUnmarshaler(#5433)
Expand Down
17 changes: 1 addition & 16 deletions component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,30 +164,15 @@ type Factory interface {
// Type gets the type of the component created by this factory.
Type() config.Type

// Deprecated: [v0.58.0] replaced by the more specific versions in each Factory type.
StabilityLevel(config.DataType) StabilityLevel

unexportedFactoryFunc()
}

type baseFactory struct {
cfgType config.Type
stability map[config.DataType]StabilityLevel
cfgType config.Type
}

func (baseFactory) unexportedFactoryFunc() {}

func (bf baseFactory) Type() config.Type {
return bf.cfgType
}

func (bf baseFactory) StabilityLevel(dt config.DataType) StabilityLevel {
return bf.getStabilityLevel(dt)
}

func (bf baseFactory) getStabilityLevel(dt config.DataType) StabilityLevel {
if val, ok := bf.stability[dt]; ok {
return val
}
return StabilityLevelUndefined
}
2 changes: 1 addition & 1 deletion component/componenttest/nop_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type nopExtensionConfig struct {

// NewNopExtensionFactory returns a component.ExtensionFactory that constructs nop extensions.
func NewNopExtensionFactory() component.ExtensionFactory {
return component.NewExtensionFactoryWithStabilityLevel(
return component.NewExtensionFactory(
"nop",
func() config.Extension {
return &nopExtensionConfig{
Expand Down
17 changes: 10 additions & 7 deletions component/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,50 +153,53 @@ type exporterFactory struct {
baseFactory
ExporterCreateDefaultConfigFunc
CreateTracesExporterFunc
tracesStabilityLevel StabilityLevel
CreateMetricsExporterFunc
metricsStabilityLevel StabilityLevel
CreateLogsExporterFunc
logsStabilityLevel StabilityLevel
}

func (e exporterFactory) TracesExporterStability() StabilityLevel {
return e.getStabilityLevel(config.TracesDataType)
return e.tracesStabilityLevel
}

func (e exporterFactory) MetricsExporterStability() StabilityLevel {
return e.getStabilityLevel(config.MetricsDataType)
return e.metricsStabilityLevel
}

func (e exporterFactory) LogsExporterStability() StabilityLevel {
return e.getStabilityLevel(config.LogsDataType)
return e.logsStabilityLevel
}

// WithTracesExporter overrides the default "error not supported" implementation for CreateTracesExporter and the default "undefined" stability level.
func WithTracesExporter(createTracesExporter CreateTracesExporterFunc, sl StabilityLevel) ExporterFactoryOption {
return exporterFactoryOptionFunc(func(o *exporterFactory) {
o.stability[config.TracesDataType] = sl
o.tracesStabilityLevel = sl
o.CreateTracesExporterFunc = createTracesExporter
})
}

// WithMetricsExporter overrides the default "error not supported" implementation for CreateMetricsExporter and the default "undefined" stability level.
func WithMetricsExporter(createMetricsExporter CreateMetricsExporterFunc, sl StabilityLevel) ExporterFactoryOption {
return exporterFactoryOptionFunc(func(o *exporterFactory) {
o.stability[config.MetricsDataType] = sl
o.metricsStabilityLevel = sl
o.CreateMetricsExporterFunc = createMetricsExporter
})
}

// WithLogsExporter overrides the default "error not supported" implementation for CreateLogsExporter and the default "undefined" stability level.
func WithLogsExporter(createLogsExporter CreateLogsExporterFunc, sl StabilityLevel) ExporterFactoryOption {
return exporterFactoryOptionFunc(func(o *exporterFactory) {
o.stability[config.LogsDataType] = sl
o.logsStabilityLevel = sl
o.CreateLogsExporterFunc = createLogsExporter
})
}

// NewExporterFactory returns a ExporterFactory.
func NewExporterFactory(cfgType config.Type, createDefaultConfig ExporterCreateDefaultConfigFunc, options ...ExporterFactoryOption) ExporterFactory {
f := &exporterFactory{
baseFactory: baseFactory{cfgType: cfgType, stability: make(map[config.DataType]StabilityLevel)},
baseFactory: baseFactory{cfgType: cfgType},
ExporterCreateDefaultConfigFunc: createDefaultConfig,
}
for _, opt := range options {
Expand Down
13 changes: 7 additions & 6 deletions component/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,17 @@ func (ef *extensionFactory) ExtensionStability() StabilityLevel {
return ef.extensionStability
}

// Deprecated: [v0.58.0] use NewExtensionFactoryWithStabilityLevel.
func NewExtensionFactory(
// Deprecated: [v0.58.0] use NewExtensionFactory.
func NewExtensionFactoryWithStabilityLevel(
cfgType config.Type,
createDefaultConfig ExtensionCreateDefaultConfigFunc,
createServiceExtension CreateExtensionFunc) ExtensionFactory {
return NewExtensionFactoryWithStabilityLevel(cfgType, createDefaultConfig, createServiceExtension, StabilityLevelUndefined)
createServiceExtension CreateExtensionFunc,
sl StabilityLevel) ExtensionFactory {
return NewExtensionFactory(cfgType, createDefaultConfig, createServiceExtension, sl)
}

// NewExtensionFactoryWithStabilityLevel returns a new ExtensionFactory based on this configuration.
func NewExtensionFactoryWithStabilityLevel(
// NewExtensionFactory returns a new ExtensionFactory based on this configuration.
func NewExtensionFactory(
cfgType config.Type,
createDefaultConfig ExtensionCreateDefaultConfigFunc,
createServiceExtension CreateExtensionFunc,
Expand Down
2 changes: 1 addition & 1 deletion component/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestNewExtensionFactory(t *testing.T) {
defaultCfg := config.NewExtensionSettings(config.NewComponentID(typeStr))
nopExtensionInstance := new(nopExtension)

factory := NewExtensionFactoryWithStabilityLevel(
factory := NewExtensionFactory(
typeStr,
func() config.Extension { return &defaultCfg },
func(ctx context.Context, settings ExtensionCreateSettings, extension config.Extension) (Extension, error) {
Expand Down
6 changes: 3 additions & 3 deletions component/factories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func TestMakeExtensionFactoryMap(t *testing.T) {
out map[config.Type]ExtensionFactory
}

p1 := NewExtensionFactoryWithStabilityLevel("p1", nil, nil, StabilityLevelAlpha)
p2 := NewExtensionFactoryWithStabilityLevel("p2", nil, nil, StabilityLevelAlpha)
p1 := NewExtensionFactory("p1", nil, nil, StabilityLevelAlpha)
p2 := NewExtensionFactory("p2", nil, nil, StabilityLevelAlpha)
testCases := []testCase{
{
name: "different names",
Expand All @@ -42,7 +42,7 @@ func TestMakeExtensionFactoryMap(t *testing.T) {
},
{
name: "same name",
in: []ExtensionFactory{p1, p2, NewExtensionFactoryWithStabilityLevel("p1", nil, nil, StabilityLevelAlpha)},
in: []ExtensionFactory{p1, p2, NewExtensionFactory("p1", nil, nil, StabilityLevelAlpha)},
},
}
for i := range testCases {
Expand Down
17 changes: 10 additions & 7 deletions component/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,50 +168,53 @@ type processorFactory struct {
baseFactory
ProcessorCreateDefaultConfigFunc
CreateTracesProcessorFunc
tracesStabilityLevel StabilityLevel
CreateMetricsProcessorFunc
metricsStabilityLevel StabilityLevel
CreateLogsProcessorFunc
logsStabilityLevel StabilityLevel
}

func (p processorFactory) TracesProcessorStability() StabilityLevel {
return p.getStabilityLevel(config.TracesDataType)
return p.tracesStabilityLevel
}

func (p processorFactory) MetricsProcessorStability() StabilityLevel {
return p.getStabilityLevel(config.MetricsDataType)
return p.metricsStabilityLevel
}

func (p processorFactory) LogsProcessorStability() StabilityLevel {
return p.getStabilityLevel(config.LogsDataType)
return p.logsStabilityLevel
}

// WithTracesProcessor overrides the default "error not supported" implementation for CreateTracesProcessor and the default "undefined" stability level.
func WithTracesProcessor(createTracesProcessor CreateTracesProcessorFunc, sl StabilityLevel) ProcessorFactoryOption {
return processorFactoryOptionFunc(func(o *processorFactory) {
o.stability[config.TracesDataType] = sl
o.tracesStabilityLevel = sl
o.CreateTracesProcessorFunc = createTracesProcessor
})
}

// WithMetricsProcessor overrides the default "error not supported" implementation for CreateMetricsProcessor and the default "undefined" stability level.
func WithMetricsProcessor(createMetricsProcessor CreateMetricsProcessorFunc, sl StabilityLevel) ProcessorFactoryOption {
return processorFactoryOptionFunc(func(o *processorFactory) {
o.stability[config.MetricsDataType] = sl
o.metricsStabilityLevel = sl
o.CreateMetricsProcessorFunc = createMetricsProcessor
})
}

// WithLogsProcessor overrides the default "error not supported" implementation for CreateLogsProcessor and the default "undefined" stability level.
func WithLogsProcessor(createLogsProcessor CreateLogsProcessorFunc, sl StabilityLevel) ProcessorFactoryOption {
return processorFactoryOptionFunc(func(o *processorFactory) {
o.stability[config.LogsDataType] = sl
o.logsStabilityLevel = sl
o.CreateLogsProcessorFunc = createLogsProcessor
})
}

// NewProcessorFactory returns a ProcessorFactory.
func NewProcessorFactory(cfgType config.Type, createDefaultConfig ProcessorCreateDefaultConfigFunc, options ...ProcessorFactoryOption) ProcessorFactory {
f := &processorFactory{
baseFactory: baseFactory{cfgType: cfgType, stability: make(map[config.DataType]StabilityLevel)},
baseFactory: baseFactory{cfgType: cfgType},
ProcessorCreateDefaultConfigFunc: createDefaultConfig,
}
for _, opt := range options {
Expand Down
17 changes: 10 additions & 7 deletions component/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,50 +213,53 @@ type receiverFactory struct {
baseFactory
ReceiverCreateDefaultConfigFunc
CreateTracesReceiverFunc
tracesStabilityLevel StabilityLevel
CreateMetricsReceiverFunc
metricsStabilityLevel StabilityLevel
CreateLogsReceiverFunc
logsStabilityLevel StabilityLevel
}

func (r receiverFactory) TracesReceiverStability() StabilityLevel {
return r.getStabilityLevel(config.TracesDataType)
return r.tracesStabilityLevel
}

func (r receiverFactory) MetricsReceiverStability() StabilityLevel {
return r.getStabilityLevel(config.MetricsDataType)
return r.metricsStabilityLevel
}

func (r receiverFactory) LogsReceiverStability() StabilityLevel {
return r.getStabilityLevel(config.LogsDataType)
return r.logsStabilityLevel
}

// WithTracesReceiver overrides the default "error not supported" implementation for CreateTracesReceiver and the default "undefined" stability level.
func WithTracesReceiver(createTracesReceiver CreateTracesReceiverFunc, sl StabilityLevel) ReceiverFactoryOption {
return receiverFactoryOptionFunc(func(o *receiverFactory) {
o.stability[config.TracesDataType] = sl
o.tracesStabilityLevel = sl
o.CreateTracesReceiverFunc = createTracesReceiver
})
}

// WithMetricsReceiver overrides the default "error not supported" implementation for CreateMetricsReceiver and the default "undefined" stability level.
func WithMetricsReceiver(createMetricsReceiver CreateMetricsReceiverFunc, sl StabilityLevel) ReceiverFactoryOption {
return receiverFactoryOptionFunc(func(o *receiverFactory) {
o.stability[config.MetricsDataType] = sl
o.metricsStabilityLevel = sl
o.CreateMetricsReceiverFunc = createMetricsReceiver
})
}

// WithLogsReceiver overrides the default "error not supported" implementation for CreateLogsReceiver and the default "undefined" stability level.
func WithLogsReceiver(createLogsReceiver CreateLogsReceiverFunc, sl StabilityLevel) ReceiverFactoryOption {
return receiverFactoryOptionFunc(func(o *receiverFactory) {
o.stability[config.LogsDataType] = sl
o.logsStabilityLevel = sl
o.CreateLogsReceiverFunc = createLogsReceiver
})
}

// NewReceiverFactory returns a ReceiverFactory.
func NewReceiverFactory(cfgType config.Type, createDefaultConfig ReceiverCreateDefaultConfigFunc, options ...ReceiverFactoryOption) ReceiverFactory {
f := &receiverFactory{
baseFactory: baseFactory{cfgType: cfgType, stability: make(map[config.DataType]StabilityLevel)},
baseFactory: baseFactory{cfgType: cfgType},
ReceiverCreateDefaultConfigFunc: createDefaultConfig,
}
for _, opt := range options {
Expand Down
2 changes: 1 addition & 1 deletion extension/ballastextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var memHandler = iruntime.TotalMemory

// NewFactory creates a factory for FluentBit extension.
func NewFactory() component.ExtensionFactory {
return component.NewExtensionFactoryWithStabilityLevel(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta)
return component.NewExtensionFactory(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta)
}

func createDefaultConfig() config.Extension {
Expand Down
2 changes: 1 addition & 1 deletion extension/zpagesextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (

// NewFactory creates a factory for Z-Pages extension.
func NewFactory() component.ExtensionFactory {
return component.NewExtensionFactoryWithStabilityLevel(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta)
return component.NewExtensionFactory(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta)
}

func createDefaultConfig() config.Extension {
Expand Down
Empty file added service/error-output-logs
Empty file.
4 changes: 2 additions & 2 deletions service/extensions/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestBuildExtensions(t *testing.T) {
}

func newBadExtensionFactory() component.ExtensionFactory {
return component.NewExtensionFactoryWithStabilityLevel(
return component.NewExtensionFactory(
"bf",
func() config.Extension {
return &struct {
Expand All @@ -123,7 +123,7 @@ func newBadExtensionFactory() component.ExtensionFactory {
}

func newCreateErrorExtensionFactory() component.ExtensionFactory {
return component.NewExtensionFactoryWithStabilityLevel(
return component.NewExtensionFactory(
"err",
func() config.Extension {
return &struct {
Expand Down

0 comments on commit fdf4885

Please sign in to comment.