Skip to content

Commit

Permalink
Mark as deprecated componenttest exporter related funcs (open-telemet…
Browse files Browse the repository at this point in the history
…ry#6707)

* Mark as deprecated componenttest exporter related funcs

This was a miss from open-telemetry#6672

Skipping changelog since covered in https://github.com/open-telemetry/opentelemetry-collector/blob/main/.chloggen/deprecatecompexp.yaml

Signed-off-by: Bogdan Drutu <[email protected]>

* Update deprecatecompexp.yaml

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
jaronoff97 committed Dec 14, 2022
1 parent f0438d4 commit 152f020
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .chloggen/deprecatecompexp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ subtext: |-
- `component.NewExporterFactory` -> `exporter.NewFactory`
- `component.MakeExporterFactoryMap` -> `exporter.MakeFactoryMap`
- `componenttest.NewNopExporterCreateSettings` -> `exportertest.NewNopCreateSettings`
- `componenttest.NewNopExporterFactory` -> `exportertest.NewNopFactory`
- `componenttest.NewNopExporterFactory` -> `exportertest.NewNopFactory`
4 changes: 2 additions & 2 deletions component/componenttest/nop_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"go.opentelemetry.io/collector/exporter"
)

// NewNopExporterCreateSettings returns a new nop settings for Create*Exporter functions.
// Deprecated: [v0.67.0] use exportertest.NewNopCreateSettings.
func NewNopExporterCreateSettings() exporter.CreateSettings {
return exporter.CreateSettings{
TelemetrySettings: NewNopTelemetrySettings(),
Expand All @@ -35,7 +35,7 @@ type nopExporterConfig struct {
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
}

// NewNopExporterFactory returns an exporter.Factory that constructs nop exporters.
// Deprecated: [v0.67.0] use exportertest.NewNopFactory.
func NewNopExporterFactory() exporter.Factory {
return exporter.NewFactory(
"nop",
Expand Down
3 changes: 2 additions & 1 deletion exporter/exporterhelper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ import (
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/pdata/ptrace"
)

var (
defaultID = component.NewID("test")
defaultSettings = func() exporter.CreateSettings {
set := componenttest.NewNopExporterCreateSettings()
set := exportertest.NewNopCreateSettings()
set.ID = defaultID
return set
}()
Expand Down
19 changes: 10 additions & 9 deletions exporter/exporterhelper/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport/obsreporttest"
Expand Down Expand Up @@ -60,7 +61,7 @@ func TestLogsRequest(t *testing.T) {
}

func TestLogsExporter_InvalidName(t *testing.T) {
le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), nil, newPushLogsData(nil))
le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), nil, newPushLogsData(nil))
require.Nil(t, le)
require.Equal(t, errNilConfig, err)
}
Expand All @@ -72,14 +73,14 @@ func TestLogsExporter_NilLogger(t *testing.T) {
}

func TestLogsExporter_NilPushLogsData(t *testing.T) {
le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, nil)
le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, nil)
require.Nil(t, le)
require.Equal(t, errNilPushLogsData, err)
}

func TestLogsExporter_Default(t *testing.T) {
ld := plog.NewLogs()
le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil))
le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil))
assert.NotNil(t, le)
assert.NoError(t, err)

Expand All @@ -91,7 +92,7 @@ func TestLogsExporter_Default(t *testing.T) {

func TestLogsExporter_WithCapabilities(t *testing.T) {
capabilities := consumer.Capabilities{MutatesData: true}
le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithCapabilities(capabilities))
le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithCapabilities(capabilities))
require.NoError(t, err)
require.NotNil(t, le)

Expand All @@ -101,7 +102,7 @@ func TestLogsExporter_WithCapabilities(t *testing.T) {
func TestLogsExporter_Default_ReturnError(t *testing.T) {
ld := plog.NewLogs()
want := errors.New("my_error")
le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(want))
le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(want))
require.NoError(t, err)
require.NotNil(t, le)
require.Equal(t, want, le.ConsumeLogs(context.Background(), ld))
Expand Down Expand Up @@ -158,7 +159,7 @@ func TestLogsExporter_WithRecordEnqueueFailedMetrics(t *testing.T) {
}

func TestLogsExporter_WithSpan(t *testing.T) {
set := componenttest.NewNopExporterCreateSettings()
set := exportertest.NewNopCreateSettings()
sr := new(tracetest.SpanRecorder)
set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))
otel.SetTracerProvider(set.TracerProvider)
Expand All @@ -171,7 +172,7 @@ func TestLogsExporter_WithSpan(t *testing.T) {
}

func TestLogsExporter_WithSpan_ReturnError(t *testing.T) {
set := componenttest.NewNopExporterCreateSettings()
set := exportertest.NewNopCreateSettings()
sr := new(tracetest.SpanRecorder)
set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))
otel.SetTracerProvider(set.TracerProvider)
Expand All @@ -188,7 +189,7 @@ func TestLogsExporter_WithShutdown(t *testing.T) {
shutdownCalled := false
shutdown := func(context.Context) error { shutdownCalled = true; return nil }

le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithShutdown(shutdown))
le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithShutdown(shutdown))
assert.NotNil(t, le)
assert.NoError(t, err)

Expand All @@ -200,7 +201,7 @@ func TestLogsExporter_WithShutdown_ReturnError(t *testing.T) {
want := errors.New("my_error")
shutdownErr := func(context.Context) error { return want }

le, err := NewLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithShutdown(shutdownErr))
le, err := NewLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeLogsExporterConfig, newPushLogsData(nil), WithShutdown(shutdownErr))
assert.NotNil(t, le)
assert.NoError(t, err)

Expand Down
19 changes: 10 additions & 9 deletions exporter/exporterhelper/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport/obsreporttest"
Expand Down Expand Up @@ -59,7 +60,7 @@ func TestMetricsRequest(t *testing.T) {
}

func TestMetricsExporter_InvalidName(t *testing.T) {
me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), nil, newPushMetricsData(nil))
me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), nil, newPushMetricsData(nil))
require.Nil(t, me)
require.Equal(t, errNilConfig, err)
}
Expand All @@ -71,14 +72,14 @@ func TestMetricsExporter_NilLogger(t *testing.T) {
}

func TestMetricsExporter_NilPushMetricsData(t *testing.T) {
me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, nil)
me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, nil)
require.Nil(t, me)
require.Equal(t, errNilPushMetricsData, err)
}

func TestMetricsExporter_Default(t *testing.T) {
md := pmetric.NewMetrics()
me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil))
me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil))
assert.NoError(t, err)
assert.NotNil(t, me)

Expand All @@ -90,7 +91,7 @@ func TestMetricsExporter_Default(t *testing.T) {

func TestMetricsExporter_WithCapabilities(t *testing.T) {
capabilities := consumer.Capabilities{MutatesData: true}
me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithCapabilities(capabilities))
me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithCapabilities(capabilities))
assert.NoError(t, err)
assert.NotNil(t, me)

Expand All @@ -100,7 +101,7 @@ func TestMetricsExporter_WithCapabilities(t *testing.T) {
func TestMetricsExporter_Default_ReturnError(t *testing.T) {
md := pmetric.NewMetrics()
want := errors.New("my_error")
me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(want))
me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(want))
require.NoError(t, err)
require.NotNil(t, me)
require.Equal(t, want, me.ConsumeMetrics(context.Background(), md))
Expand Down Expand Up @@ -157,7 +158,7 @@ func TestMetricsExporter_WithRecordEnqueueFailedMetrics(t *testing.T) {
}

func TestMetricsExporter_WithSpan(t *testing.T) {
set := componenttest.NewNopExporterCreateSettings()
set := exportertest.NewNopCreateSettings()
sr := new(tracetest.SpanRecorder)
set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))
otel.SetTracerProvider(set.TracerProvider)
Expand All @@ -170,7 +171,7 @@ func TestMetricsExporter_WithSpan(t *testing.T) {
}

func TestMetricsExporter_WithSpan_ReturnError(t *testing.T) {
set := componenttest.NewNopExporterCreateSettings()
set := exportertest.NewNopCreateSettings()
sr := new(tracetest.SpanRecorder)
set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))
otel.SetTracerProvider(set.TracerProvider)
Expand All @@ -187,7 +188,7 @@ func TestMetricsExporter_WithShutdown(t *testing.T) {
shutdownCalled := false
shutdown := func(context.Context) error { shutdownCalled = true; return nil }

me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithShutdown(shutdown))
me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithShutdown(shutdown))
assert.NotNil(t, me)
assert.NoError(t, err)

Expand All @@ -200,7 +201,7 @@ func TestMetricsExporter_WithShutdown_ReturnError(t *testing.T) {
want := errors.New("my_error")
shutdownErr := func(context.Context) error { return want }

me, err := NewMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithShutdown(shutdownErr))
me, err := NewMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeMetricsExporterConfig, newPushMetricsData(nil), WithShutdown(shutdownErr))
assert.NotNil(t, me)
assert.NoError(t, err)

Expand Down
19 changes: 10 additions & 9 deletions exporter/exporterhelper/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport/obsreporttest"
Expand All @@ -55,7 +56,7 @@ func TestTracesRequest(t *testing.T) {
}

func TestTracesExporter_InvalidName(t *testing.T) {
te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), nil, newTraceDataPusher(nil))
te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), nil, newTraceDataPusher(nil))
require.Nil(t, te)
require.Equal(t, errNilConfig, err)
}
Expand All @@ -67,14 +68,14 @@ func TestTracesExporter_NilLogger(t *testing.T) {
}

func TestTracesExporter_NilPushTraceData(t *testing.T) {
te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, nil)
te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, nil)
require.Nil(t, te)
require.Equal(t, errNilPushTraceData, err)
}

func TestTracesExporter_Default(t *testing.T) {
td := ptrace.NewTraces()
te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil))
te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil))
assert.NotNil(t, te)
assert.NoError(t, err)

Expand All @@ -86,7 +87,7 @@ func TestTracesExporter_Default(t *testing.T) {

func TestTracesExporter_WithCapabilities(t *testing.T) {
capabilities := consumer.Capabilities{MutatesData: true}
te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithCapabilities(capabilities))
te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithCapabilities(capabilities))
assert.NotNil(t, te)
assert.NoError(t, err)

Expand All @@ -96,7 +97,7 @@ func TestTracesExporter_WithCapabilities(t *testing.T) {
func TestTracesExporter_Default_ReturnError(t *testing.T) {
td := ptrace.NewTraces()
want := errors.New("my_error")
te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(want))
te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(want))
require.NoError(t, err)
require.NotNil(t, te)

Expand Down Expand Up @@ -155,7 +156,7 @@ func TestTracesExporter_WithRecordEnqueueFailedMetrics(t *testing.T) {
}

func TestTracesExporter_WithSpan(t *testing.T) {
set := componenttest.NewNopExporterCreateSettings()
set := exportertest.NewNopCreateSettings()
sr := new(tracetest.SpanRecorder)
set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))
otel.SetTracerProvider(set.TracerProvider)
Expand All @@ -169,7 +170,7 @@ func TestTracesExporter_WithSpan(t *testing.T) {
}

func TestTracesExporter_WithSpan_ReturnError(t *testing.T) {
set := componenttest.NewNopExporterCreateSettings()
set := exportertest.NewNopCreateSettings()
sr := new(tracetest.SpanRecorder)
set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))
otel.SetTracerProvider(set.TracerProvider)
Expand All @@ -187,7 +188,7 @@ func TestTracesExporter_WithShutdown(t *testing.T) {
shutdownCalled := false
shutdown := func(context.Context) error { shutdownCalled = true; return nil }

te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithShutdown(shutdown))
te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithShutdown(shutdown))
assert.NotNil(t, te)
assert.NoError(t, err)

Expand All @@ -200,7 +201,7 @@ func TestTracesExporter_WithShutdown_ReturnError(t *testing.T) {
want := errors.New("my_error")
shutdownErr := func(context.Context) error { return want }

te, err := NewTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithShutdown(shutdownErr))
te, err := NewTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), &fakeTracesExporterConfig, newTraceDataPusher(nil), WithShutdown(shutdownErr))
assert.NotNil(t, te)
assert.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions exporter/exportertest/nop_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

// NewNopCreateSettings returns a new nop settings for Create*Exporter functions.
var NewNopCreateSettings = componenttest.NewNopExporterCreateSettings
var NewNopCreateSettings = componenttest.NewNopExporterCreateSettings //nolint:staticcheck

// NewNopFactory returns an exporter.Factory that constructs nop exporters.
var NewNopFactory = componenttest.NewNopExporterFactory
var NewNopFactory = componenttest.NewNopExporterFactory //nolint:staticcheck
6 changes: 3 additions & 3 deletions exporter/exportertest/nop_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ func TestNewNopFactory(t *testing.T) {
cfg := factory.CreateDefaultConfig()
// assert.Equal(t, &nopExporterConfig{ExporterSettings: config.NewExporterSettings(component.NewID("nop"))}, cfg)

traces, err := factory.CreateTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg)
traces, err := factory.CreateTracesExporter(context.Background(), NewNopCreateSettings(), cfg)
require.NoError(t, err)
assert.NoError(t, traces.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, traces.ConsumeTraces(context.Background(), ptrace.NewTraces()))
assert.NoError(t, traces.Shutdown(context.Background()))

metrics, err := factory.CreateMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg)
metrics, err := factory.CreateMetricsExporter(context.Background(), NewNopCreateSettings(), cfg)
require.NoError(t, err)
assert.NoError(t, metrics.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pmetric.NewMetrics()))
assert.NoError(t, metrics.Shutdown(context.Background()))

logs, err := factory.CreateLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg)
logs, err := factory.CreateLogsExporter(context.Background(), NewNopCreateSettings(), cfg)
require.NoError(t, err)
assert.NoError(t, logs.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, logs.ConsumeLogs(context.Background(), plog.NewLogs()))
Expand Down
7 changes: 4 additions & 3 deletions exporter/loggingexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/stretchr/testify/assert"

"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/exporter/exportertest"
)

func TestCreateDefaultConfig(t *testing.T) {
Expand All @@ -34,7 +35,7 @@ func TestCreateMetricsExporter(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

me, err := factory.CreateMetricsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg)
me, err := factory.CreateMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg)
assert.NoError(t, err)
assert.NotNil(t, me)
}
Expand All @@ -43,7 +44,7 @@ func TestCreateTracesExporter(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

te, err := factory.CreateTracesExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg)
te, err := factory.CreateTracesExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg)
assert.NoError(t, err)
assert.NotNil(t, te)
}
Expand All @@ -52,7 +53,7 @@ func TestCreateLogsExporter(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

te, err := factory.CreateLogsExporter(context.Background(), componenttest.NewNopExporterCreateSettings(), cfg)
te, err := factory.CreateLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), cfg)
assert.NoError(t, err)
assert.NotNil(t, te)
}
Loading

0 comments on commit 152f020

Please sign in to comment.