Skip to content

Commit

Permalink
Move configerror.ErrDataTypeIsNotSupported to componenterror.ErrDataT…
Browse files Browse the repository at this point in the history
…ypeIsNotSupported

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Apr 2, 2021
1 parent 4aeef52 commit ba479c5
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 76 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Remove `configtest.NewViperFromYamlFile()`, use `config.Parser.NewParserFromFile()` (#2806)
- Move `config.ViperSubExact()` to use `config.Parser.Sub()` (#2806)
- Update LoadReceiver signature to remove unused params (#2823)
- Move `configerror.ErrDataTypeIsNotSupported` to `componenterror.ErrDataTypeIsNotSupported` (#2886)

## 💡 Enhancements 💡

Expand Down
5 changes: 5 additions & 0 deletions component/componenterror/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ var (

// ErrNilNextConsumer indicates an error on nil next consumer.
ErrNilNextConsumer = errors.New("nil nextConsumer")

// ErrDataTypeIsNotSupported can be returned by receiver, exporter or processor
// factory methods that create the entity if the particular telemetry
// data type is not supported by the receiver, exporter or processor.
ErrDataTypeIsNotSupported = errors.New("telemetry type is not supported")
)
4 changes: 2 additions & 2 deletions component/componenttest/shutdown_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/internal/testdata"
)
Expand All @@ -39,7 +39,7 @@ func verifyTraceProcessorDoesntProduceAfterShutdown(t *testing.T, factory compon
nextSink,
)
if err != nil {
if err == configerror.ErrDataTypeIsNotSupported {
if err == componenterror.ErrDataTypeIsNotSupported {
return
}
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions component/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/stretchr/testify/assert"

"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configerror"
)

type TestExporterFactory struct {
Expand All @@ -40,17 +40,17 @@ func (f *TestExporterFactory) CreateDefaultConfig() config.Exporter {

// CreateTraceExporter creates a trace exporter based on this config.
func (f *TestExporterFactory) CreateTracesExporter(context.Context, ExporterCreateParams, config.Exporter) (TracesExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateMetricsExporter creates a metrics exporter based on this config.
func (f *TestExporterFactory) CreateMetricsExporter(context.Context, ExporterCreateParams, config.Exporter) (MetricsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateMetricsExporter creates a logs exporter based on this config.
func (f *TestExporterFactory) CreateLogsExporter(context.Context, ExporterCreateParams, config.Exporter) (LogsExporter, error) {
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

func TestBuildExporters(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions component/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/stretchr/testify/assert"

"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/consumer"
)

Expand All @@ -41,17 +41,17 @@ func (f *TestProcessorFactory) CreateDefaultConfig() config.Processor {

// CreateTraceProcessor creates a trace processor based on this config.
func (f *TestProcessorFactory) CreateTracesProcessor(context.Context, ProcessorCreateParams, config.Processor, consumer.Traces) (TracesProcessor, error) {
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateMetricsProcessor creates a metrics processor based on this config.
func (f *TestProcessorFactory) CreateMetricsProcessor(context.Context, ProcessorCreateParams, config.Processor, consumer.Metrics) (MetricsProcessor, error) {
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateMetricsProcessor creates a metrics processor based on this config.
func (f *TestProcessorFactory) CreateLogsProcessor(context.Context, ProcessorCreateParams, config.Processor, consumer.Logs) (LogsProcessor, error) {
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

func TestFactoriesBuilder(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions component/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/stretchr/testify/assert"

"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/consumer"
)

Expand All @@ -41,17 +41,17 @@ func (f *TestReceiverFactory) CreateDefaultConfig() config.Receiver {

// CreateTraceReceiver creates a trace receiver based on this config.
func (f *TestReceiverFactory) CreateTracesReceiver(context.Context, ReceiverCreateParams, config.Receiver, consumer.Traces) (TracesReceiver, error) {
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateMetricsReceiver creates a metrics receiver based on this config.
func (f *TestReceiverFactory) CreateMetricsReceiver(context.Context, ReceiverCreateParams, config.Receiver, consumer.Metrics) (MetricsReceiver, error) {
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateMetricsReceiver creates a metrics receiver based on this config.
func (f *TestReceiverFactory) CreateLogsReceiver(context.Context, ReceiverCreateParams, config.Receiver, consumer.Logs) (LogsReceiver, error) {
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

func TestBuildReceivers(t *testing.T) {
Expand Down
23 changes: 0 additions & 23 deletions config/configerror/configerror.go

This file was deleted.

8 changes: 4 additions & 4 deletions exporter/exporterhelper/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/spf13/viper"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configerror"
)

// FactoryOption apply changes to ExporterOptions.
Expand Down Expand Up @@ -115,7 +115,7 @@ func (f *factory) CreateTracesExporter(
if f.createTracesExporter != nil {
return f.createTracesExporter(ctx, params, cfg)
}
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateMetricsExporter creates a component.MetricsExporter based on this config.
Expand All @@ -126,7 +126,7 @@ func (f *factory) CreateMetricsExporter(
if f.createMetricsExporter != nil {
return f.createMetricsExporter(ctx, params, cfg)
}
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateLogsExporter creates a metrics processor based on this config.
Expand All @@ -138,7 +138,7 @@ func (f *factory) CreateLogsExporter(
if f.createLogsExporter != nil {
return f.createLogsExporter(ctx, params, cfg)
}
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

var _ component.ConfigUnmarshaler = (*factoryWithUnmarshaler)(nil)
Expand Down
8 changes: 4 additions & 4 deletions exporter/exporterhelper/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/consumer/pdata"
)

Expand Down Expand Up @@ -56,11 +56,11 @@ func TestNewFactory(t *testing.T) {
_, ok := factory.(component.ConfigUnmarshaler)
assert.False(t, ok)
_, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, defaultCfg)
assert.Equal(t, configerror.ErrDataTypeIsNotSupported, err)
assert.Equal(t, componenterror.ErrDataTypeIsNotSupported, err)
_, err = factory.CreateMetricsExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, defaultCfg)
assert.Equal(t, configerror.ErrDataTypeIsNotSupported, err)
assert.Equal(t, componenterror.ErrDataTypeIsNotSupported, err)
_, err = factory.CreateLogsExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, defaultCfg)
assert.Equal(t, configerror.ErrDataTypeIsNotSupported, err)
assert.Equal(t, componenterror.ErrDataTypeIsNotSupported, err)
}

func TestNewFactory_WithConstructors(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions exporter/jaegerexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config/configcheck"
"go.opentelemetry.io/collector/config/configerror"
)

func TestCreateDefaultConfig(t *testing.T) {
Expand All @@ -39,7 +39,7 @@ func TestCreateMetricsExporter(t *testing.T) {

params := component.ExporterCreateParams{Logger: zap.NewNop()}
_, err := factory.CreateMetricsExporter(context.Background(), params, cfg)
assert.Error(t, err, configerror.ErrDataTypeIsNotSupported)
assert.Error(t, err, componenterror.ErrDataTypeIsNotSupported)
}

func TestCreateInstanceViaFactory(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions processor/attributesprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configcheck"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/processor/processorhelper"
)
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestFactory_CreateMetricsProcessor(t *testing.T) {

mp, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, nil)
require.Nil(t, mp)
assert.Equal(t, err, configerror.ErrDataTypeIsNotSupported)
assert.Equal(t, err, componenterror.ErrDataTypeIsNotSupported)
}

func TestFactoryCreateLogsProcessor_EmptyActions(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions processor/processorhelper/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/spf13/viper"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/consumer"
)

Expand Down Expand Up @@ -118,7 +118,7 @@ func (f *factory) CreateTracesProcessor(
if f.createTraceProcessor != nil {
return f.createTraceProcessor(ctx, params, cfg, nextConsumer)
}
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateMetricsProcessor creates a component.MetricsProcessor based on this config.
Expand All @@ -131,7 +131,7 @@ func (f *factory) CreateMetricsProcessor(
if f.createMetricsProcessor != nil {
return f.createMetricsProcessor(ctx, params, cfg, nextConsumer)
}
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateLogsProcessor creates a component.LogsProcessor based on this config.
Expand All @@ -144,7 +144,7 @@ func (f *factory) CreateLogsProcessor(
if f.createLogsProcessor != nil {
return f.createLogsProcessor(ctx, params, cfg, nextConsumer)
}
return nil, configerror.ErrDataTypeIsNotSupported
return nil, componenterror.ErrDataTypeIsNotSupported
}

var _ component.ConfigUnmarshaler = (*factoryWithUnmarshaler)(nil)
Expand Down
4 changes: 2 additions & 2 deletions processor/spanprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configcheck"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/consumer/consumertest"
)

Expand Down Expand Up @@ -103,5 +103,5 @@ func TestFactory_CreateMetricProcessor(t *testing.T) {

mp, err := factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateParams{Logger: zap.NewNop()}, cfg, nil)
require.Nil(t, mp)
assert.Equal(t, err, configerror.ErrDataTypeIsNotSupported)
assert.Equal(t, err, componenterror.ErrDataTypeIsNotSupported)
}
6 changes: 3 additions & 3 deletions receiver/hostmetricsreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config/configcheck"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal"
)
Expand All @@ -43,15 +43,15 @@ func TestCreateReceiver(t *testing.T) {
cfg := factory.CreateDefaultConfig()

tReceiver, err := factory.CreateTracesReceiver(context.Background(), creationParams, cfg, consumertest.NewTracesNop())
assert.Equal(t, err, configerror.ErrDataTypeIsNotSupported)
assert.Equal(t, err, componenterror.ErrDataTypeIsNotSupported)
assert.Nil(t, tReceiver)

mReceiver, err := factory.CreateMetricsReceiver(context.Background(), creationParams, cfg, consumertest.NewMetricsNop())
assert.NoError(t, err)
assert.NotNil(t, mReceiver)

tLogs, err := factory.CreateLogsReceiver(context.Background(), creationParams, cfg, consumertest.NewLogsNop())
assert.Equal(t, err, configerror.ErrDataTypeIsNotSupported)
assert.Equal(t, err, componenterror.ErrDataTypeIsNotSupported)
assert.Nil(t, tLogs)
}

Expand Down
6 changes: 3 additions & 3 deletions receiver/jaegerreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configcheck"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/confignet"
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestCreateReceiver(t *testing.T) {
assert.NotNil(t, tReceiver, "receiver creation failed")

mReceiver, err := factory.CreateMetricsReceiver(context.Background(), params, cfg, nil)
assert.Equal(t, err, configerror.ErrDataTypeIsNotSupported)
assert.Equal(t, err, componenterror.ErrDataTypeIsNotSupported)
assert.Nil(t, mReceiver)
}

Expand All @@ -89,7 +89,7 @@ func TestCreateReceiverGeneralConfig(t *testing.T) {
assert.NotNil(t, tReceiver, "receiver creation failed")

mReceiver, err := factory.CreateMetricsReceiver(context.Background(), params, rCfg, nil)
assert.Equal(t, err, configerror.ErrDataTypeIsNotSupported)
assert.Equal(t, err, componenterror.ErrDataTypeIsNotSupported)
assert.Nil(t, mReceiver)
}

Expand Down
Loading

0 comments on commit ba479c5

Please sign in to comment.