Skip to content

Commit

Permalink
Deprecate funcs that repeate exporter in name (#11370)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Oct 9, 2024
1 parent cceb6c1 commit 738b9df
Show file tree
Hide file tree
Showing 36 changed files with 574 additions and 466 deletions.
27 changes: 27 additions & 0 deletions .chloggen/rm-dup-exporter.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: exporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate funcs that repeate exporter in name

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

# (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]Exporter -> Factory.Create[Traces|Metrics|Logs|Profiles] |
Factory.[Traces|Metrics|Logs|Profiles]ExporterStability -> 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 @@ -76,23 +76,23 @@ func TestComponentLifecycle(t *testing.T) {
{
name: "logs",
createFn: func(ctx context.Context, set exporter.Settings, cfg component.Config) (component.Component, error) {
return factory.CreateLogsExporter(ctx, set, cfg)
return factory.CreateLogs(ctx, set, cfg)
},
},
{{ end }}
{{ if supportsMetrics }}
{
name: "metrics",
createFn: func(ctx context.Context, set exporter.Settings, cfg component.Config) (component.Component, error) {
return factory.CreateMetricsExporter(ctx, set, cfg)
return factory.CreateMetrics(ctx, set, cfg)
},
},
{{ end }}
{{ if supportsTraces }}
{
name: "traces",
createFn: func(ctx context.Context, set exporter.Settings, cfg component.Config) (component.Component, error) {
return factory.CreateTracesExporter(ctx, set, cfg)
return factory.CreateTraces(ctx, set, cfg)
},
},
{{ end }}
Expand Down
6 changes: 3 additions & 3 deletions exporter/debugexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func newDebugExporter(logger *zap.Logger, verbosity configtelemetry.Level) *debu
}

func (s *debugExporter) pushTraces(_ context.Context, td ptrace.Traces) error {
s.logger.Info("TracesExporter",
s.logger.Info("Traces",
zap.Int("resource spans", td.ResourceSpans().Len()),
zap.Int("spans", td.SpanCount()))
if s.verbosity == configtelemetry.LevelBasic {
Expand All @@ -63,7 +63,7 @@ func (s *debugExporter) pushTraces(_ context.Context, td ptrace.Traces) error {
}

func (s *debugExporter) pushMetrics(_ context.Context, md pmetric.Metrics) error {
s.logger.Info("MetricsExporter",
s.logger.Info("Metrics",
zap.Int("resource metrics", md.ResourceMetrics().Len()),
zap.Int("metrics", md.MetricCount()),
zap.Int("data points", md.DataPointCount()))
Expand All @@ -80,7 +80,7 @@ func (s *debugExporter) pushMetrics(_ context.Context, md pmetric.Metrics) error
}

func (s *debugExporter) pushLogs(_ context.Context, ld plog.Logs) error {
s.logger.Info("LogsExporter",
s.logger.Info("Logs",
zap.Int("resource logs", ld.ResourceLogs().Len()),
zap.Int("log records", ld.LogRecordCount()))

Expand Down
14 changes: 7 additions & 7 deletions exporter/debugexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"go.opentelemetry.io/collector/pdata/testdata"
)

func TestTracesExporterNoErrors(t *testing.T) {
func TestTracesNoErrors(t *testing.T) {
for _, tc := range createTestCases() {
t.Run(tc.name, func(t *testing.T) {
lte, err := createTracesExporter(context.Background(), exportertest.NewNopSettings(), tc.config)
lte, err := createTraces(context.Background(), exportertest.NewNopSettings(), tc.config)
require.NotNil(t, lte)
assert.NoError(t, err)

Expand All @@ -35,10 +35,10 @@ func TestTracesExporterNoErrors(t *testing.T) {
}
}

func TestMetricsExporterNoErrors(t *testing.T) {
func TestMetricsNoErrors(t *testing.T) {
for _, tc := range createTestCases() {
t.Run(tc.name, func(t *testing.T) {
lme, err := createMetricsExporter(context.Background(), exportertest.NewNopSettings(), tc.config)
lme, err := createMetrics(context.Background(), exportertest.NewNopSettings(), tc.config)
require.NotNil(t, lme)
assert.NoError(t, err)

Expand All @@ -53,10 +53,10 @@ func TestMetricsExporterNoErrors(t *testing.T) {
}
}

func TestLogsExporterNoErrors(t *testing.T) {
func TestLogsNoErrors(t *testing.T) {
for _, tc := range createTestCases() {
t.Run(tc.name, func(t *testing.T) {
lle, err := createLogsExporter(context.Background(), exportertest.NewNopSettings(), createDefaultConfig())
lle, err := createLogs(context.Background(), exportertest.NewNopSettings(), createDefaultConfig())
require.NotNil(t, lle)
assert.NoError(t, err)

Expand All @@ -68,7 +68,7 @@ func TestLogsExporterNoErrors(t *testing.T) {
}
}

func TestExporterErrors(t *testing.T) {
func TestErrors(t *testing.T) {
le := newDebugExporter(zaptest.NewLogger(t), configtelemetry.LevelDetailed)
require.NotNil(t, le)

Expand Down
30 changes: 15 additions & 15 deletions exporter/debugexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func NewFactory() exporter.Factory {
return exporter.NewFactory(
componentType,
createDefaultConfig,
exporter.WithTraces(createTracesExporter, metadata.TracesStability),
exporter.WithMetrics(createMetricsExporter, metadata.MetricsStability),
exporter.WithLogs(createLogsExporter, metadata.LogsStability),
exporter.WithTraces(createTraces, metadata.TracesStability),
exporter.WithMetrics(createMetrics, metadata.MetricsStability),
exporter.WithLogs(createLogs, metadata.LogsStability),
)
}

Expand All @@ -47,36 +47,36 @@ func createDefaultConfig() component.Config {
}
}

func createTracesExporter(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Traces, error) {
func createTraces(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Traces, error) {
cfg := config.(*Config)
exporterLogger := createLogger(cfg, set.TelemetrySettings.Logger)
debugExporter := newDebugExporter(exporterLogger, cfg.Verbosity)
return exporterhelper.NewTracesExporter(ctx, set, config,
debugExporter.pushTraces,
debug := newDebugExporter(exporterLogger, cfg.Verbosity)
return exporterhelper.NewTraces(ctx, set, config,
debug.pushTraces,
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
exporterhelper.WithTimeout(exporterhelper.TimeoutConfig{Timeout: 0}),
exporterhelper.WithShutdown(otlptext.LoggerSync(exporterLogger)),
)
}

func createMetricsExporter(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Metrics, error) {
func createMetrics(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Metrics, error) {
cfg := config.(*Config)
exporterLogger := createLogger(cfg, set.TelemetrySettings.Logger)
debugExporter := newDebugExporter(exporterLogger, cfg.Verbosity)
return exporterhelper.NewMetricsExporter(ctx, set, config,
debugExporter.pushMetrics,
debug := newDebugExporter(exporterLogger, cfg.Verbosity)
return exporterhelper.NewMetrics(ctx, set, config,
debug.pushMetrics,
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
exporterhelper.WithTimeout(exporterhelper.TimeoutConfig{Timeout: 0}),
exporterhelper.WithShutdown(otlptext.LoggerSync(exporterLogger)),
)
}

func createLogsExporter(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Logs, error) {
func createLogs(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Logs, error) {
cfg := config.(*Config)
exporterLogger := createLogger(cfg, set.TelemetrySettings.Logger)
debugExporter := newDebugExporter(exporterLogger, cfg.Verbosity)
return exporterhelper.NewLogsExporter(ctx, set, config,
debugExporter.pushLogs,
debug := newDebugExporter(exporterLogger, cfg.Verbosity)
return exporterhelper.NewLogs(ctx, set, config,
debug.pushLogs,
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
exporterhelper.WithTimeout(exporterhelper.TimeoutConfig{Timeout: 0}),
exporterhelper.WithShutdown(otlptext.LoggerSync(exporterLogger)),
Expand Down
12 changes: 6 additions & 6 deletions exporter/debugexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ func TestCreateDefaultConfig(t *testing.T) {
assert.NoError(t, componenttest.CheckConfigStruct(cfg))
}

func TestCreateMetricsExporter(t *testing.T) {
func TestCreateMetrics(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

me, err := factory.CreateMetricsExporter(context.Background(), exportertest.NewNopSettings(), cfg)
me, err := factory.CreateMetrics(context.Background(), exportertest.NewNopSettings(), cfg)
require.NoError(t, err)
assert.NotNil(t, me)
}

func TestCreateTracesExporter(t *testing.T) {
func TestCreateTraces(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

te, err := factory.CreateTracesExporter(context.Background(), exportertest.NewNopSettings(), cfg)
te, err := factory.CreateTraces(context.Background(), exportertest.NewNopSettings(), cfg)
require.NoError(t, err)
assert.NotNil(t, te)
}

func TestCreateLogsExporter(t *testing.T) {
func TestCreateLogs(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

te, err := factory.CreateLogsExporter(context.Background(), exportertest.NewNopSettings(), cfg)
te, err := factory.CreateLogs(context.Background(), exportertest.NewNopSettings(), cfg)
require.NoError(t, err)
assert.NotNil(t, te)
}
6 changes: 3 additions & 3 deletions exporter/debugexporter/generated_component_test.go

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

Loading

0 comments on commit 738b9df

Please sign in to comment.