Skip to content

Commit

Permalink
Deprecate funcs that repeate processor in name (open-telemetry#11310)
Browse files Browse the repository at this point in the history
Similar with
open-telemetry#11287

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored and jackgopack4 committed Oct 8, 2024
1 parent d41d7f9 commit adf50db
Show file tree
Hide file tree
Showing 29 changed files with 289 additions and 218 deletions.
27 changes: 27 additions & 0 deletions .chloggen/deprecate-processor-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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 funcs that repeat "processor" in name

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

# (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: |
Factory.Create[Traces|Metrics|Logs|Profiles]Processor -> Factory.Create[Traces|Metrics|Logs|Profiles]
Factory.[Traces|Metrics|Logs|Profiles]ProcessorStability -> Factory.[Traces|Metrics|Logs|Profiles]Stability
# 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]
6 changes: 3 additions & 3 deletions cmd/mdatagen/internal/templates/component_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,23 @@ func TestComponentLifecycle(t *testing.T) {
{
name: "logs",
createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) {
return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop())
return factory.CreateLogs(ctx, set, cfg, consumertest.NewNop())
},
},
{{ end }}
{{ if supportsMetrics }}
{
name: "metrics",
createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) {
return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop())
return factory.CreateMetrics(ctx, set, cfg, consumertest.NewNop())
},
},
{{ end }}
{{ if supportsTraces }}
{
name: "traces",
createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) {
return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop())
return factory.CreateTraces(ctx, set, cfg, consumertest.NewNop())
},
},
{{ end }}
Expand Down
6 changes: 3 additions & 3 deletions otelcol/command_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func newComponentsCommand(set CollectorSettings) *cobra.Command {
Name: prs.Type(),
Module: factories.ProcessorModules[prs.Type()],
Stability: map[string]string{
"logs": prs.LogsProcessorStability().String(),
"metrics": prs.MetricsProcessorStability().String(),
"traces": prs.TracesProcessorStability().String(),
"logs": prs.LogsStability().String(),
"metrics": prs.MetricsStability().String(),
"traces": prs.TracesStability().String(),
},
})
}
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 @@ -353,22 +353,22 @@ func (mb *multiShardBatcher) currentMetadataCardinality() int {
return mb.size
}

// ConsumeTraces implements TracesProcessor
// ConsumeTraces implements processor.Traces
func (bp *batchProcessor) ConsumeTraces(ctx context.Context, td ptrace.Traces) error {
return bp.batcher.consume(ctx, td)
}

// ConsumeMetrics implements MetricsProcessor
// ConsumeMetrics implements processor.Metrics
func (bp *batchProcessor) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error {
return bp.batcher.consume(ctx, md)
}

// ConsumeLogs implements LogsProcessor
// ConsumeLogs implements processor.Logs
func (bp *batchProcessor) ConsumeLogs(ctx context.Context, ld plog.Logs) error {
return bp.batcher.consume(ctx, ld)
}

// newBatchTracesProcessor creates a new batch processor that batches traces by size or with timeout
// newBatchTraces creates a new batch processor that batches traces by size or with timeout
func newBatchTracesProcessor(set processor.Settings, next consumer.Traces, cfg *Config) (*batchProcessor, error) {
return newBatchProcessor(set, cfg, func() batch { return newBatchTraces(next) })
}
Expand Down
12 changes: 6 additions & 6 deletions processor/batchprocessor/batch_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ func TestProcessorShutdown(t *testing.T) {

for i := 0; i < 5; i++ {
require.NotPanics(t, func() {
tProc, err := factory.CreateTracesProcessor(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
tProc, err := factory.CreateTraces(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
require.NoError(t, err)
_ = tProc.Shutdown(ctx)
})

require.NotPanics(t, func() {
mProc, err := factory.CreateMetricsProcessor(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
mProc, err := factory.CreateMetrics(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
require.NoError(t, err)
_ = mProc.Shutdown(ctx)
})

require.NotPanics(t, func() {
lProc, err := factory.CreateLogsProcessor(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
lProc, err := factory.CreateLogs(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
require.NoError(t, err)
_ = lProc.Shutdown(ctx)
})
Expand All @@ -63,17 +63,17 @@ func TestProcessorLifecycle(t *testing.T) {
processorCreationSet := processortest.NewNopSettings()

for i := 0; i < 5; i++ {
tProc, err := factory.CreateTracesProcessor(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
tProc, err := factory.CreateTraces(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
require.NoError(t, err)
require.NoError(t, tProc.Start(ctx, componenttest.NewNopHost()))
require.NoError(t, tProc.Shutdown(ctx))

mProc, err := factory.CreateMetricsProcessor(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
mProc, err := factory.CreateMetrics(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
require.NoError(t, err)
require.NoError(t, mProc.Start(ctx, componenttest.NewNopHost()))
require.NoError(t, mProc.Shutdown(ctx))

lProc, err := factory.CreateLogsProcessor(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
lProc, err := factory.CreateLogs(ctx, processorCreationSet, factory.CreateDefaultConfig(), consumertest.NewNop())
require.NoError(t, err)
require.NoError(t, lProc.Start(ctx, componenttest.NewNopHost()))
require.NoError(t, lProc.Shutdown(ctx))
Expand Down
6 changes: 3 additions & 3 deletions processor/batchprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ func TestCreateProcessor(t *testing.T) {

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

mp, err := factory.CreateMetricsProcessor(context.Background(), creationSet, cfg, nil)
mp, err := factory.CreateMetrics(context.Background(), creationSet, cfg, nil)
assert.NotNil(t, mp)
assert.NoError(t, err, "cannot create metric processor")
assert.NoError(t, mp.Shutdown(context.Background()))

lp, err := factory.CreateLogsProcessor(context.Background(), creationSet, cfg, nil)
lp, err := factory.CreateLogs(context.Background(), creationSet, cfg, nil)
assert.NotNil(t, lp)
assert.NoError(t, err, "cannot create logs processor")
assert.NoError(t, lp.Shutdown(context.Background()))
Expand Down
6 changes: 3 additions & 3 deletions processor/batchprocessor/generated_component_test.go

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

18 changes: 9 additions & 9 deletions processor/memorylimiterprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func NewFactory() processor.Factory {
return processor.NewFactory(
metadata.Type,
createDefaultConfig,
processor.WithTraces(f.createTracesProcessor, metadata.TracesStability),
processor.WithMetrics(f.createMetricsProcessor, metadata.MetricsStability),
processor.WithLogs(f.createLogsProcessor, metadata.LogsStability))
processor.WithTraces(f.createTraces, metadata.TracesStability),
processor.WithMetrics(f.createMetrics, metadata.MetricsStability),
processor.WithLogs(f.createLogs, metadata.LogsStability))
}

// CreateDefaultConfig creates the default configuration for processor. Notice
Expand All @@ -44,7 +44,7 @@ func createDefaultConfig() component.Config {
return &Config{}
}

func (f *factory) createTracesProcessor(
func (f *factory) createTraces(
ctx context.Context,
set processor.Settings,
cfg component.Config,
Expand All @@ -54,14 +54,14 @@ func (f *factory) createTracesProcessor(
if err != nil {
return nil, err
}
return processorhelper.NewTracesProcessor(ctx, set, cfg, nextConsumer,
return processorhelper.NewTraces(ctx, set, cfg, nextConsumer,
memLimiter.processTraces,
processorhelper.WithCapabilities(processorCapabilities),
processorhelper.WithStart(memLimiter.start),
processorhelper.WithShutdown(memLimiter.shutdown))
}

func (f *factory) createMetricsProcessor(
func (f *factory) createMetrics(
ctx context.Context,
set processor.Settings,
cfg component.Config,
Expand All @@ -71,14 +71,14 @@ func (f *factory) createMetricsProcessor(
if err != nil {
return nil, err
}
return processorhelper.NewMetricsProcessor(ctx, set, cfg, nextConsumer,
return processorhelper.NewMetrics(ctx, set, cfg, nextConsumer,
memLimiter.processMetrics,
processorhelper.WithCapabilities(processorCapabilities),
processorhelper.WithStart(memLimiter.start),
processorhelper.WithShutdown(memLimiter.shutdown))
}

func (f *factory) createLogsProcessor(
func (f *factory) createLogs(
ctx context.Context,
set processor.Settings,
cfg component.Config,
Expand All @@ -88,7 +88,7 @@ func (f *factory) createLogsProcessor(
if err != nil {
return nil, err
}
return processorhelper.NewLogsProcessor(ctx, set, cfg, nextConsumer,
return processorhelper.NewLogs(ctx, set, cfg, nextConsumer,
memLimiter.processLogs,
processorhelper.WithCapabilities(processorCapabilities),
processorhelper.WithStart(memLimiter.start),
Expand Down
6 changes: 3 additions & 3 deletions processor/memorylimiterprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ func TestCreateProcessor(t *testing.T) {
pCfg.MemorySpikeLimitMiB = 1907
pCfg.CheckInterval = 100 * time.Millisecond

tp, err := factory.CreateTracesProcessor(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop())
tp, err := factory.CreateTraces(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop())
require.NoError(t, err)
assert.NotNil(t, tp)
// test if we can shutdown a monitoring routine that has not started
require.ErrorIs(t, tp.Shutdown(context.Background()), memorylimiter.ErrShutdownNotStarted)
require.NoError(t, tp.Start(context.Background(), componenttest.NewNopHost()))

mp, err := factory.CreateMetricsProcessor(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop())
mp, err := factory.CreateMetrics(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop())
require.NoError(t, err)
assert.NotNil(t, mp)
require.NoError(t, mp.Start(context.Background(), componenttest.NewNopHost()))

lp, err := factory.CreateLogsProcessor(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop())
lp, err := factory.CreateLogs(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop())
require.NoError(t, err)
assert.NotNil(t, lp)
assert.NoError(t, lp.Start(context.Background(), componenttest.NewNopHost()))
Expand Down
6 changes: 3 additions & 3 deletions processor/memorylimiterprocessor/generated_component_test.go

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

8 changes: 4 additions & 4 deletions processor/memorylimiterprocessor/memorylimiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestNoDataLoss(t *testing.T) {
limiter, err := newMemoryLimiterProcessor(set, cfg)
require.NoError(t, err)

processor, err := processorhelper.NewLogsProcessor(context.Background(), processor.Settings{
processor, err := processorhelper.NewLogs(context.Background(), processor.Settings{
ID: component.MustNewID("nop"),
TelemetrySettings: componenttest.NewNopTelemetrySettings(),
}, cfg, exporter,
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestMetricsMemoryPressureResponse(t *testing.T) {

ml, err := newMemoryLimiterProcessor(processortest.NewNopSettings(), tt.mlCfg)
require.NoError(t, err)
mp, err := processorhelper.NewMetricsProcessor(
mp, err := processorhelper.NewMetrics(
context.Background(),
processortest.NewNopSettings(),
tt.mlCfg,
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestTraceMemoryPressureResponse(t *testing.T) {

ml, err := newMemoryLimiterProcessor(processortest.NewNopSettings(), tt.mlCfg)
require.NoError(t, err)
tp, err := processorhelper.NewTracesProcessor(
tp, err := processorhelper.NewTraces(
context.Background(),
processortest.NewNopSettings(),
tt.mlCfg,
Expand Down Expand Up @@ -356,7 +356,7 @@ func TestLogMemoryPressureResponse(t *testing.T) {

ml, err := newMemoryLimiterProcessor(processortest.NewNopSettings(), tt.mlCfg)
require.NoError(t, err)
tp, err := processorhelper.NewLogsProcessor(
tp, err := processorhelper.NewLogs(
context.Background(),
processortest.NewNopSettings(),
tt.mlCfg,
Expand Down
Loading

0 comments on commit adf50db

Please sign in to comment.