Skip to content

Commit

Permalink
[processor] deprecate CreateSettings -> Settings (#10336)
Browse files Browse the repository at this point in the history
This deprecates CreateSettings in favour of Settings.
NewNopCreateSettings is also being deprecated in favour of
NewNopSettings
    
Part of #9428

---------

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten authored Jun 6, 2024
1 parent 88acdf0 commit 9907ba5
Show file tree
Hide file tree
Showing 34 changed files with 187 additions and 147 deletions.
28 changes: 28 additions & 0 deletions .chloggen/codeboten_create-settings-processor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use this changelog template to create an entry for release notes.

# 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: processor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate CreateSettings and NewNopCreateSettings

# One or more tracking issues or pull requests related to the change
issues: [9428]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
The following methods are being renamed:
- processor.CreateSettings -> processor.Settings
- processor.NewNopCreateSettings -> processor.NewNopSettings
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
2 changes: 1 addition & 1 deletion cmd/mdatagen/templates/component_telemetry_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type componentTestTelemetry struct {
meterProvider *sdkmetric.MeterProvider
}

{{- if (or isExporter isReceiver) }}
{{- if (or isExporter isReceiver isProcessor) }}
func (tt *componentTestTelemetry) NewSettings() {{ .Status.Class }}.Settings {
settings := {{ .Status.Class }}test.NewNopSettings()
settings.MeterProvider = tt.meterProvider
Expand Down
12 changes: 6 additions & 6 deletions cmd/mdatagen/templates/component_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -166,28 +166,28 @@ func TestComponentLifecycle(t *testing.T) {

tests := []struct{
name string
createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error)
createFn func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error)
}{
{{ if supportsLogs }}
{
name: "logs",
createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) {
createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) {
return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop())
},
},
{{ end }}
{{ if supportsMetrics }}
{
name: "metrics",
createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) {
createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) {
return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop())
},
},
{{ end }}
{{ if supportsTraces }}
{
name: "traces",
createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) {
createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) {
return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop())
},
},
Expand All @@ -204,7 +204,7 @@ func TestComponentLifecycle(t *testing.T) {
for _, test := range tests {
{{- if not .Tests.SkipShutdown }}
t.Run(test.name + "-shutdown", func(t *testing.T) {
c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg)
c, err := test.createFn(context.Background(), processortest.NewNopSettings(), cfg)
require.NoError(t, err)
err = c.Shutdown(context.Background())
require.NoError(t, err)
Expand All @@ -213,7 +213,7 @@ func TestComponentLifecycle(t *testing.T) {

{{- if not .Tests.SkipLifecycle }}
t.Run(test.name + "-lifecycle", func(t *testing.T) {
c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg)
c, err := test.createFn(context.Background(), processortest.NewNopSettings(), cfg)
require.NoError(t, err)
host := componenttest.NewNopHost()
err = c.Start(context.Background(), host)
Expand Down
8 changes: 4 additions & 4 deletions processor/batchprocessor/batch_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ var _ consumer.Metrics = (*batchProcessor)(nil)
var _ consumer.Logs = (*batchProcessor)(nil)

// newBatchProcessor returns a new batch processor component.
func newBatchProcessor(set processor.CreateSettings, cfg *Config, batchFunc func() batch) (*batchProcessor, error) {
func newBatchProcessor(set processor.Settings, cfg *Config, batchFunc func() batch) (*batchProcessor, error) {
// use lower-case, to be consistent with http/2 headers.
mks := make([]string, len(cfg.MetadataKeys))
for i, k := range cfg.MetadataKeys {
Expand Down Expand Up @@ -357,17 +357,17 @@ func (bp *batchProcessor) ConsumeLogs(ctx context.Context, ld plog.Logs) error {
}

// newBatchTracesProcessor creates a new batch processor that batches traces by size or with timeout
func newBatchTracesProcessor(set processor.CreateSettings, next consumer.Traces, cfg *Config) (*batchProcessor, error) {
func newBatchTracesProcessor(set processor.Settings, next consumer.Traces, cfg *Config) (*batchProcessor, error) {
return newBatchProcessor(set, cfg, func() batch { return newBatchTraces(next) })
}

// newBatchMetricsProcessor creates a new batch processor that batches metrics by size or with timeout
func newBatchMetricsProcessor(set processor.CreateSettings, next consumer.Metrics, cfg *Config) (*batchProcessor, error) {
func newBatchMetricsProcessor(set processor.Settings, next consumer.Metrics, cfg *Config) (*batchProcessor, error) {
return newBatchProcessor(set, cfg, func() batch { return newBatchMetrics(next) })
}

// newBatchLogsProcessor creates a new batch processor that batches logs by size or with timeout
func newBatchLogsProcessor(set processor.CreateSettings, next consumer.Logs, cfg *Config) (*batchProcessor, error) {
func newBatchLogsProcessor(set processor.Settings, next consumer.Logs, cfg *Config) (*batchProcessor, error) {
return newBatchProcessor(set, cfg, func() batch { return newBatchLogs(next) })
}

Expand Down
42 changes: 21 additions & 21 deletions processor/batchprocessor/batch_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestProcessorShutdown(t *testing.T) {
factory := NewFactory()

ctx := context.Background()
processorCreationSet := processortest.NewNopCreateSettings()
processorCreationSet := processortest.NewNopSettings()

for i := 0; i < 5; i++ {
require.NotPanics(t, func() {
Expand All @@ -60,7 +60,7 @@ func TestProcessorLifecycle(t *testing.T) {
factory := NewFactory()

ctx := context.Background()
processorCreationSet := processortest.NewNopCreateSettings()
processorCreationSet := processortest.NewNopSettings()

for i := 0; i < 5; i++ {
tProc, err := factory.CreateTracesProcessor(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
Expand All @@ -84,7 +84,7 @@ func TestBatchProcessorSpansDelivered(t *testing.T) {
sink := new(consumertest.TracesSink)
cfg := createDefaultConfig().(*Config)
cfg.SendBatchSize = 128
creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchTracesProcessor(creationSet, sink, cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestBatchProcessorSpansDeliveredEnforceBatchSize(t *testing.T) {
cfg := createDefaultConfig().(*Config)
cfg.SendBatchSize = 128
cfg.SendBatchMaxSize = 130
creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchTracesProcessor(creationSet, sink, cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -174,7 +174,7 @@ func TestBatchProcessorSentBySize(t *testing.T) {
sendBatchSize := 20
cfg.SendBatchSize = uint32(sendBatchSize)
cfg.Timeout = 500 * time.Millisecond
creationSet := tel.NewCreateSettings()
creationSet := tel.NewSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchTracesProcessor(creationSet, sink, cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -295,7 +295,7 @@ func TestBatchProcessorSentBySizeWithMaxSize(t *testing.T) {
cfg.SendBatchSize = uint32(sendBatchSize)
cfg.SendBatchMaxSize = uint32(sendBatchMaxSize)
cfg.Timeout = 500 * time.Millisecond
creationSet := tel.NewCreateSettings()
creationSet := tel.NewSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchTracesProcessor(creationSet, sink, cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -437,7 +437,7 @@ func TestBatchProcessorSentByTimeout(t *testing.T) {
spansPerRequest := 10
start := time.Now()

creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchTracesProcessor(creationSet, sink, cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -484,7 +484,7 @@ func TestBatchProcessorTraceSendWhenClosing(t *testing.T) {
}
sink := new(consumertest.TracesSink)

creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchTracesProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -515,7 +515,7 @@ func TestBatchMetricProcessor_ReceivingData(t *testing.T) {
metricsPerRequest := 5
sink := new(consumertest.MetricsSink)

creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchMetricsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -569,7 +569,7 @@ func TestBatchMetricProcessorBatchSize(t *testing.T) {
dataPointsPerRequest := metricsPerRequest * dataPointsPerMetric
sink := new(consumertest.MetricsSink)

creationSet := tel.NewCreateSettings()
creationSet := tel.NewSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchMetricsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -702,7 +702,7 @@ func TestBatchMetricsProcessor_Timeout(t *testing.T) {
metricsPerRequest := 10
sink := new(consumertest.MetricsSink)

creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchMetricsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -751,7 +751,7 @@ func TestBatchMetricProcessor_Shutdown(t *testing.T) {
metricsPerRequest := 10
sink := new(consumertest.MetricsSink)

creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchMetricsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -849,7 +849,7 @@ func BenchmarkMultiBatchMetricProcessor(b *testing.B) {
func runMetricsProcessorBenchmark(b *testing.B, cfg Config) {
ctx := context.Background()
sink := new(metricsSink)
creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
metricsPerRequest := 1000
batcher, err := newBatchMetricsProcessor(creationSet, sink, &cfg)
Expand Down Expand Up @@ -897,7 +897,7 @@ func TestBatchLogProcessor_ReceivingData(t *testing.T) {
logsPerRequest := 5
sink := new(consumertest.LogsSink)

creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchLogsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -949,7 +949,7 @@ func TestBatchLogProcessor_BatchSize(t *testing.T) {
logsPerRequest := 5
sink := new(consumertest.LogsSink)

creationSet := tel.NewCreateSettings()
creationSet := tel.NewSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchLogsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -1063,7 +1063,7 @@ func TestBatchLogsProcessor_Timeout(t *testing.T) {
logsPerRequest := 10
sink := new(consumertest.LogsSink)

creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchLogsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -1112,7 +1112,7 @@ func TestBatchLogProcessor_Shutdown(t *testing.T) {
logsPerRequest := 10
sink := new(consumertest.LogsSink)

creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchLogsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -1191,7 +1191,7 @@ func TestBatchProcessorSpansBatchedByMetadata(t *testing.T) {
cfg.SendBatchSize = 1000
cfg.Timeout = 10 * time.Minute
cfg.MetadataKeys = []string{"token1", "token2"}
creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchTracesProcessor(creationSet, sink, cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -1285,7 +1285,7 @@ func TestBatchProcessorMetadataCardinalityLimit(t *testing.T) {
cfg := createDefaultConfig().(*Config)
cfg.MetadataKeys = []string{"token"}
cfg.MetadataCardinalityLimit = cardLimit
creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
batcher, err := newBatchTracesProcessor(creationSet, sink, cfg)
require.NoError(t, err)
require.NoError(t, batcher.Start(context.Background(), componenttest.NewNopHost()))
Expand Down Expand Up @@ -1327,7 +1327,7 @@ func TestBatchZeroConfig(t *testing.T) {
const requestCount = 5
const logsPerRequest = 10
sink := new(consumertest.LogsSink)
creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchLogsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down Expand Up @@ -1368,7 +1368,7 @@ func TestBatchSplitOnly(t *testing.T) {
require.NoError(t, cfg.Validate())

sink := new(consumertest.LogsSink)
creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
creationSet.MetricsLevel = configtelemetry.LevelDetailed
batcher, err := newBatchLogsProcessor(creationSet, sink, &cfg)
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions processor/batchprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func createDefaultConfig() component.Config {

func createTraces(
_ context.Context,
set processor.CreateSettings,
set processor.Settings,
cfg component.Config,
nextConsumer consumer.Traces,
) (processor.Traces, error) {
Expand All @@ -54,7 +54,7 @@ func createTraces(

func createMetrics(
_ context.Context,
set processor.CreateSettings,
set processor.Settings,
cfg component.Config,
nextConsumer consumer.Metrics,
) (processor.Metrics, error) {
Expand All @@ -63,7 +63,7 @@ func createMetrics(

func createLogs(
_ context.Context,
set processor.CreateSettings,
set processor.Settings,
cfg component.Config,
nextConsumer consumer.Logs,
) (processor.Logs, error) {
Expand Down
2 changes: 1 addition & 1 deletion processor/batchprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestCreateProcessor(t *testing.T) {
factory := NewFactory()

cfg := factory.CreateDefaultConfig()
creationSet := processortest.NewNopCreateSettings()
creationSet := processortest.NewNopSettings()
tp, err := factory.CreateTracesProcessor(context.Background(), creationSet, cfg, nil)
assert.NotNil(t, tp)
assert.NoError(t, err, "cannot create trace processor")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9907ba5

Please sign in to comment.