Skip to content

Commit 80a415d

Browse files
authored
Move configerror.ErrDataTypeIsNotSupported to componenterror.ErrDataTypeIsNotSupported (#2886)
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 7c2a541 commit 80a415d

File tree

21 files changed

+62
-79
lines changed

21 files changed

+62
-79
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- Remove `configtest.NewViperFromYamlFile()`, use `config.Parser.NewParserFromFile()` (#2806)
2323
- Move `config.ViperSubExact()` to use `config.Parser.Sub()` (#2806)
2424
- Update LoadReceiver signature to remove unused params (#2823)
25+
- Move `configerror.ErrDataTypeIsNotSupported` to `componenterror.ErrDataTypeIsNotSupported` (#2886)
2526

2627
## 💡 Enhancements 💡
2728

component/componenterror/errors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ var (
2929

3030
// ErrNilNextConsumer indicates an error on nil next consumer.
3131
ErrNilNextConsumer = errors.New("nil nextConsumer")
32+
33+
// ErrDataTypeIsNotSupported can be returned by receiver, exporter or processor
34+
// factory methods that create the entity if the particular telemetry
35+
// data type is not supported by the receiver, exporter or processor.
36+
ErrDataTypeIsNotSupported = errors.New("telemetry type is not supported")
3237
)

component/componenttest/shutdown_verifier.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
"go.uber.org/zap"
2424

2525
"go.opentelemetry.io/collector/component"
26+
"go.opentelemetry.io/collector/component/componenterror"
2627
"go.opentelemetry.io/collector/config"
27-
"go.opentelemetry.io/collector/config/configerror"
2828
"go.opentelemetry.io/collector/consumer/consumertest"
2929
"go.opentelemetry.io/collector/internal/testdata"
3030
)
@@ -39,7 +39,7 @@ func verifyTraceProcessorDoesntProduceAfterShutdown(t *testing.T, factory compon
3939
nextSink,
4040
)
4141
if err != nil {
42-
if err == configerror.ErrDataTypeIsNotSupported {
42+
if err == componenterror.ErrDataTypeIsNotSupported {
4343
return
4444
}
4545
require.NoError(t, err)

component/exporter_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020

2121
"github.com/stretchr/testify/assert"
2222

23+
"go.opentelemetry.io/collector/component/componenterror"
2324
"go.opentelemetry.io/collector/config"
24-
"go.opentelemetry.io/collector/config/configerror"
2525
)
2626

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

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

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

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

5656
func TestBuildExporters(t *testing.T) {

component/processor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919

2020
"go.uber.org/zap"
2121

22+
"go.opentelemetry.io/collector/component/componenterror"
2223
"go.opentelemetry.io/collector/config"
23-
"go.opentelemetry.io/collector/config/configerror"
2424
"go.opentelemetry.io/collector/consumer"
2525
)
2626

@@ -139,17 +139,17 @@ func (b BaseProcessorFactory) CreateDefaultConfig() config.Processor {
139139

140140
// CreateTracesProcessor default implemented as not supported date type.
141141
func (b BaseProcessorFactory) CreateTracesProcessor(context.Context, ProcessorCreateParams, config.Processor, consumer.Traces) (TracesProcessor, error) {
142-
return nil, configerror.ErrDataTypeIsNotSupported
142+
return nil, componenterror.ErrDataTypeIsNotSupported
143143
}
144144

145145
// CreateMetricsProcessor default implemented as not supported date type.
146146
func (b BaseProcessorFactory) CreateMetricsProcessor(context.Context, ProcessorCreateParams, config.Processor, consumer.Metrics) (MetricsProcessor, error) {
147-
return nil, configerror.ErrDataTypeIsNotSupported
147+
return nil, componenterror.ErrDataTypeIsNotSupported
148148
}
149149

150150
// CreateLogsProcessor default implemented as not supported date type.
151151
func (b BaseProcessorFactory) CreateLogsProcessor(context.Context, ProcessorCreateParams, config.Processor, consumer.Logs) (LogsProcessor, error) {
152-
return nil, configerror.ErrDataTypeIsNotSupported
152+
return nil, componenterror.ErrDataTypeIsNotSupported
153153
}
154154

155155
func (b BaseProcessorFactory) unexportedProcessor() {}

component/processor_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020

2121
"github.com/stretchr/testify/assert"
2222

23+
"go.opentelemetry.io/collector/component/componenterror"
2324
"go.opentelemetry.io/collector/config"
24-
"go.opentelemetry.io/collector/config/configerror"
2525
"go.opentelemetry.io/collector/consumer/consumertest"
2626
)
2727

@@ -85,10 +85,10 @@ func TestBaseProcessorFactory(t *testing.T) {
8585
bpf.CreateDefaultConfig()
8686
})
8787
assert.NotPanics(t, bpf.unexportedProcessor)
88-
_, err := bpf.CreateTracesProcessor(context.Background(), ProcessorCreateParams{}, config.NewProcessorSettings("nop"), consumertest.NewTracesNop())
89-
assert.ErrorIs(t, err, configerror.ErrDataTypeIsNotSupported)
90-
_, err = bpf.CreateMetricsProcessor(context.Background(), ProcessorCreateParams{}, config.NewProcessorSettings("nop"), consumertest.NewMetricsNop())
91-
assert.ErrorIs(t, err, configerror.ErrDataTypeIsNotSupported)
92-
_, err = bpf.CreateLogsProcessor(context.Background(), ProcessorCreateParams{}, config.NewProcessorSettings("nop"), consumertest.NewLogsNop())
93-
assert.ErrorIs(t, err, configerror.ErrDataTypeIsNotSupported)
88+
_, err := bpf.CreateTracesProcessor(context.Background(), ProcessorCreateParams{}, config.NewProcessorSettings("nop"), consumertest.NewNop())
89+
assert.ErrorIs(t, err, componenterror.ErrDataTypeIsNotSupported)
90+
_, err = bpf.CreateMetricsProcessor(context.Background(), ProcessorCreateParams{}, config.NewProcessorSettings("nop"), consumertest.NewNop())
91+
assert.ErrorIs(t, err, componenterror.ErrDataTypeIsNotSupported)
92+
_, err = bpf.CreateLogsProcessor(context.Background(), ProcessorCreateParams{}, config.NewProcessorSettings("nop"), consumertest.NewNop())
93+
assert.ErrorIs(t, err, componenterror.ErrDataTypeIsNotSupported)
9494
}

component/receiver_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020

2121
"github.com/stretchr/testify/assert"
2222

23+
"go.opentelemetry.io/collector/component/componenterror"
2324
"go.opentelemetry.io/collector/config"
24-
"go.opentelemetry.io/collector/config/configerror"
2525
"go.opentelemetry.io/collector/consumer"
2626
)
2727

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

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

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

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

5757
func TestBuildReceivers(t *testing.T) {

config/configerror/configerror.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

exporter/exporterhelper/factory.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"github.com/spf13/viper"
2121

2222
"go.opentelemetry.io/collector/component"
23+
"go.opentelemetry.io/collector/component/componenterror"
2324
"go.opentelemetry.io/collector/config"
24-
"go.opentelemetry.io/collector/config/configerror"
2525
)
2626

2727
// FactoryOption apply changes to ExporterOptions.
@@ -115,7 +115,7 @@ func (f *factory) CreateTracesExporter(
115115
if f.createTracesExporter != nil {
116116
return f.createTracesExporter(ctx, params, cfg)
117117
}
118-
return nil, configerror.ErrDataTypeIsNotSupported
118+
return nil, componenterror.ErrDataTypeIsNotSupported
119119
}
120120

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

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

144144
var _ component.ConfigUnmarshaler = (*factoryWithUnmarshaler)(nil)

exporter/exporterhelper/factory_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"go.uber.org/zap"
2525

2626
"go.opentelemetry.io/collector/component"
27+
"go.opentelemetry.io/collector/component/componenterror"
2728
"go.opentelemetry.io/collector/config"
28-
"go.opentelemetry.io/collector/config/configerror"
2929
"go.opentelemetry.io/collector/consumer/pdata"
3030
)
3131

@@ -56,11 +56,11 @@ func TestNewFactory(t *testing.T) {
5656
_, ok := factory.(component.ConfigUnmarshaler)
5757
assert.False(t, ok)
5858
_, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, defaultCfg)
59-
assert.Equal(t, configerror.ErrDataTypeIsNotSupported, err)
59+
assert.Equal(t, componenterror.ErrDataTypeIsNotSupported, err)
6060
_, err = factory.CreateMetricsExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, defaultCfg)
61-
assert.Equal(t, configerror.ErrDataTypeIsNotSupported, err)
61+
assert.Equal(t, componenterror.ErrDataTypeIsNotSupported, err)
6262
_, err = factory.CreateLogsExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, defaultCfg)
63-
assert.Equal(t, configerror.ErrDataTypeIsNotSupported, err)
63+
assert.Equal(t, componenterror.ErrDataTypeIsNotSupported, err)
6464
}
6565

6666
func TestNewFactory_WithConstructors(t *testing.T) {

0 commit comments

Comments
 (0)