Skip to content

Commit 0f75efa

Browse files
authored
Fix all TraceExporter usages, use TracesExporter (#2937)
* Fix all TraceExporter usages, use TracesExporter Signed-off-by: Bogdan Drutu <[email protected]> * Update changelog Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 6458914 commit 0f75efa

37 files changed

+125
-124
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Remove `testutil.WaitFor`, use `testify.Eventually` helper if needed (#2920)
1515
- Remove testutil.WaitForPort, users can use testify.Eventually (#2926)
1616
- Rename `processorhelper.NewTraceProcessor` to `processorhelper.NewTracesProcessor` (#2935)
17+
- Rename `exporterhelper.NewTraceExporter` to `exporterhelper.NewTracesExporter` (#2937)
1718

1819
## 💡 Enhancements 💡
1920

component/exporter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (f *TestExporterFactory) CreateDefaultConfig() config.Exporter {
3838
return nil
3939
}
4040

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

exporter/exporterhelper/factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ type factory struct {
4646
}
4747

4848
// WithTraces overrides the default "error not supported" implementation for CreateTracesReceiver.
49-
func WithTraces(createTraceExporter CreateTracesExporter) FactoryOption {
49+
func WithTraces(createTracesExporter CreateTracesExporter) FactoryOption {
5050
return func(o *factory) {
51-
o.createTracesExporter = createTraceExporter
51+
o.createTracesExporter = createTracesExporter
5252
}
5353
}
5454

exporter/exporterhelper/factory_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
TypeVal: typeStr,
3535
NameVal: typeStr,
3636
}
37-
nopTracesExporter, _ = NewTraceExporter(defaultCfg, zap.NewNop(), func(ctx context.Context, td pdata.Traces) error {
37+
nopTracesExporter, _ = NewTracesExporter(defaultCfg, zap.NewNop(), func(ctx context.Context, td pdata.Traces) error {
3838
return nil
3939
})
4040
nopMetricsExporter, _ = NewMetricsExporter(defaultCfg, zap.NewNop(), func(ctx context.Context, md pdata.Metrics) error {
@@ -63,7 +63,7 @@ func TestNewFactory_WithConstructors(t *testing.T) {
6363
factory := NewFactory(
6464
typeStr,
6565
defaultConfig,
66-
WithTraces(createTraceExporter),
66+
WithTraces(createTracesExporter),
6767
WithMetrics(createMetricsExporter),
6868
WithLogs(createLogsExporter))
6969
assert.EqualValues(t, typeStr, factory.Type())
@@ -86,7 +86,7 @@ func defaultConfig() config.Exporter {
8686
return defaultCfg
8787
}
8888

89-
func createTraceExporter(context.Context, component.ExporterCreateParams, config.Exporter) (component.TracesExporter, error) {
89+
func createTracesExporter(context.Context, component.ExporterCreateParams, config.Exporter) (component.TracesExporter, error) {
9090
return nopTracesExporter, nil
9191
}
9292

exporter/exporterhelper/logshelper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func generateLogsTraffic(t *testing.T, le component.LogsExporter, numRequests in
183183
}
184184

185185
func checkWrapSpanForLogsExporter(t *testing.T, le component.LogsExporter, wantError error, numLogRecords int64) {
186-
ocSpansSaver := new(testOCTraceExporter)
186+
ocSpansSaver := new(testOCTracesExporter)
187187
trace.RegisterExporter(ocSpansSaver)
188188
defer trace.UnregisterExporter(ocSpansSaver)
189189

exporter/exporterhelper/metricshelper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func generateMetricsTraffic(t *testing.T, me component.MetricsExporter, numReque
204204
}
205205

206206
func checkWrapSpanForMetricsExporter(t *testing.T, me component.MetricsExporter, wantError error, numMetricPoints int64) {
207-
ocSpansSaver := new(testOCTraceExporter)
207+
ocSpansSaver := new(testOCTracesExporter)
208208
trace.RegisterExporter(ocSpansSaver)
209209
defer trace.UnregisterExporter(ocSpansSaver)
210210

exporter/exporterhelper/tracehelper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func (texp *traceExporter) ConsumeTraces(ctx context.Context, td pdata.Traces) e
7070
return texp.sender.send(newTracesRequest(ctx, td, texp.pusher))
7171
}
7272

73-
// NewTraceExporter creates a TracesExporter that records observability metrics and wraps every request with a Span.
74-
func NewTraceExporter(
73+
// NewTracesExporter creates a TracesExporter that records observability metrics and wraps every request with a Span.
74+
func NewTracesExporter(
7575
cfg config.Exporter,
7676
logger *zap.Logger,
7777
pusher PushTraces,

exporter/exporterhelper/tracehelper_test.go

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ import (
3434
)
3535

3636
const (
37-
fakeTraceExporterType = "fake_trace_exporter"
38-
fakeTraceExporterName = "fake_trace_exporter/with_name"
37+
fakeTracesExporterType = "fake_traces_exporter"
38+
fakeTracesExporterName = "fake_traces_exporter/with_name"
3939
fakeTraceParentSpanName = "fake_trace_parent_span_name"
4040
)
4141

4242
var (
43-
fakeTraceExporterConfig = &config.ExporterSettings{
44-
TypeVal: fakeTraceExporterType,
45-
NameVal: fakeTraceExporterName,
43+
fakeTracesExporterConfig = &config.ExporterSettings{
44+
TypeVal: fakeTracesExporterType,
45+
NameVal: fakeTracesExporterName,
4646
}
4747
)
4848

@@ -53,108 +53,108 @@ func TestTracesRequest(t *testing.T) {
5353
assert.EqualValues(t, newTracesRequest(context.Background(), testdata.GenerateTraceDataEmpty(), nil), mr.onError(traceErr))
5454
}
5555

56-
type testOCTraceExporter struct {
56+
type testOCTracesExporter struct {
5757
mu sync.Mutex
5858
spanData []*trace.SpanData
5959
}
6060

61-
func (tote *testOCTraceExporter) ExportSpan(sd *trace.SpanData) {
61+
func (tote *testOCTracesExporter) ExportSpan(sd *trace.SpanData) {
6262
tote.mu.Lock()
6363
defer tote.mu.Unlock()
6464

6565
tote.spanData = append(tote.spanData, sd)
6666
}
6767

68-
func TestTraceExporter_InvalidName(t *testing.T) {
69-
te, err := NewTraceExporter(nil, zap.NewNop(), newTraceDataPusher(nil))
68+
func TestTracesExporter_InvalidName(t *testing.T) {
69+
te, err := NewTracesExporter(nil, zap.NewNop(), newTraceDataPusher(nil))
7070
require.Nil(t, te)
7171
require.Equal(t, errNilConfig, err)
7272
}
7373

74-
func TestTraceExporter_NilLogger(t *testing.T) {
75-
te, err := NewTraceExporter(fakeTraceExporterConfig, nil, newTraceDataPusher(nil))
74+
func TestTracesExporter_NilLogger(t *testing.T) {
75+
te, err := NewTracesExporter(fakeTracesExporterConfig, nil, newTraceDataPusher(nil))
7676
require.Nil(t, te)
7777
require.Equal(t, errNilLogger, err)
7878
}
7979

80-
func TestTraceExporter_NilPushTraceData(t *testing.T) {
81-
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), nil)
80+
func TestTracesExporter_NilPushTraceData(t *testing.T) {
81+
te, err := NewTracesExporter(fakeTracesExporterConfig, zap.NewNop(), nil)
8282
require.Nil(t, te)
8383
require.Equal(t, errNilPushTraceData, err)
8484
}
8585

86-
func TestTraceExporter_Default(t *testing.T) {
86+
func TestTracesExporter_Default(t *testing.T) {
8787
td := pdata.NewTraces()
88-
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(nil))
88+
te, err := NewTracesExporter(fakeTracesExporterConfig, zap.NewNop(), newTraceDataPusher(nil))
8989
assert.NotNil(t, te)
9090
assert.NoError(t, err)
9191

9292
assert.Nil(t, te.ConsumeTraces(context.Background(), td))
9393
assert.Nil(t, te.Shutdown(context.Background()))
9494
}
9595

96-
func TestTraceExporter_Default_ReturnError(t *testing.T) {
96+
func TestTracesExporter_Default_ReturnError(t *testing.T) {
9797
td := pdata.NewTraces()
9898
want := errors.New("my_error")
99-
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(want))
99+
te, err := NewTracesExporter(fakeTracesExporterConfig, zap.NewNop(), newTraceDataPusher(want))
100100
require.Nil(t, err)
101101
require.NotNil(t, te)
102102

103103
err = te.ConsumeTraces(context.Background(), td)
104104
require.Equal(t, want, err)
105105
}
106106

107-
func TestTraceExporter_WithRecordMetrics(t *testing.T) {
108-
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(nil))
107+
func TestTracesExporter_WithRecordMetrics(t *testing.T) {
108+
te, err := NewTracesExporter(fakeTracesExporterConfig, zap.NewNop(), newTraceDataPusher(nil))
109109
require.Nil(t, err)
110110
require.NotNil(t, te)
111111

112-
checkRecordedMetricsForTraceExporter(t, te, nil)
112+
checkRecordedMetricsForTracesExporter(t, te, nil)
113113
}
114114

115-
func TestTraceExporter_WithRecordMetrics_ReturnError(t *testing.T) {
115+
func TestTracesExporter_WithRecordMetrics_ReturnError(t *testing.T) {
116116
want := errors.New("my_error")
117-
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(want))
117+
te, err := NewTracesExporter(fakeTracesExporterConfig, zap.NewNop(), newTraceDataPusher(want))
118118
require.Nil(t, err)
119119
require.NotNil(t, te)
120120

121-
checkRecordedMetricsForTraceExporter(t, te, want)
121+
checkRecordedMetricsForTracesExporter(t, te, want)
122122
}
123123

124-
func TestTraceExporter_WithSpan(t *testing.T) {
125-
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(nil))
124+
func TestTracesExporter_WithSpan(t *testing.T) {
125+
te, err := NewTracesExporter(fakeTracesExporterConfig, zap.NewNop(), newTraceDataPusher(nil))
126126
require.Nil(t, err)
127127
require.NotNil(t, te)
128128

129-
checkWrapSpanForTraceExporter(t, te, nil, 1)
129+
checkWrapSpanForTracesExporter(t, te, nil, 1)
130130
}
131131

132-
func TestTraceExporter_WithSpan_ReturnError(t *testing.T) {
132+
func TestTracesExporter_WithSpan_ReturnError(t *testing.T) {
133133
want := errors.New("my_error")
134-
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(want))
134+
te, err := NewTracesExporter(fakeTracesExporterConfig, zap.NewNop(), newTraceDataPusher(want))
135135
require.Nil(t, err)
136136
require.NotNil(t, te)
137137

138-
checkWrapSpanForTraceExporter(t, te, want, 1)
138+
checkWrapSpanForTracesExporter(t, te, want, 1)
139139
}
140140

141-
func TestTraceExporter_WithShutdown(t *testing.T) {
141+
func TestTracesExporter_WithShutdown(t *testing.T) {
142142
shutdownCalled := false
143143
shutdown := func(context.Context) error { shutdownCalled = true; return nil }
144144

145-
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(nil), WithShutdown(shutdown))
145+
te, err := NewTracesExporter(fakeTracesExporterConfig, zap.NewNop(), newTraceDataPusher(nil), WithShutdown(shutdown))
146146
assert.NotNil(t, te)
147147
assert.NoError(t, err)
148148

149149
assert.Nil(t, te.Shutdown(context.Background()))
150150
assert.True(t, shutdownCalled)
151151
}
152152

153-
func TestTraceExporter_WithShutdown_ReturnError(t *testing.T) {
153+
func TestTracesExporter_WithShutdown_ReturnError(t *testing.T) {
154154
want := errors.New("my_error")
155155
shutdownErr := func(context.Context) error { return want }
156156

157-
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(nil), WithShutdown(shutdownErr))
157+
te, err := NewTracesExporter(fakeTracesExporterConfig, zap.NewNop(), newTraceDataPusher(nil), WithShutdown(shutdownErr))
158158
assert.NotNil(t, te)
159159
assert.NoError(t, err)
160160

@@ -167,7 +167,7 @@ func newTraceDataPusher(retError error) PushTraces {
167167
}
168168
}
169169

170-
func checkRecordedMetricsForTraceExporter(t *testing.T, te component.TracesExporter, wantError error) {
170+
func checkRecordedMetricsForTracesExporter(t *testing.T, te component.TracesExporter, wantError error) {
171171
doneFn, err := obsreporttest.SetupRecordedMetricsTest()
172172
require.NoError(t, err)
173173
defer doneFn()
@@ -180,9 +180,9 @@ func checkRecordedMetricsForTraceExporter(t *testing.T, te component.TracesExpor
180180

181181
// TODO: When the new metrics correctly count partial dropped fix this.
182182
if wantError != nil {
183-
obsreporttest.CheckExporterTracesViews(t, fakeTraceExporterName, 0, int64(numBatches*td.SpanCount()))
183+
obsreporttest.CheckExporterTracesViews(t, fakeTracesExporterName, 0, int64(numBatches*td.SpanCount()))
184184
} else {
185-
obsreporttest.CheckExporterTracesViews(t, fakeTraceExporterName, int64(numBatches*td.SpanCount()), 0)
185+
obsreporttest.CheckExporterTracesViews(t, fakeTracesExporterName, int64(numBatches*td.SpanCount()), 0)
186186
}
187187
}
188188

@@ -199,8 +199,8 @@ func generateTraceTraffic(t *testing.T, te component.TracesExporter, numRequests
199199
}
200200
}
201201

202-
func checkWrapSpanForTraceExporter(t *testing.T, te component.TracesExporter, wantError error, numSpans int64) {
203-
ocSpansSaver := new(testOCTraceExporter)
202+
func checkWrapSpanForTracesExporter(t *testing.T, te component.TracesExporter, wantError error, numSpans int64) {
203+
ocSpansSaver := new(testOCTracesExporter)
204204
trace.RegisterExporter(ocSpansSaver)
205205
defer trace.UnregisterExporter(ocSpansSaver)
206206

exporter/fileexporter/factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func NewFactory() component.ExporterFactory {
3333
return exporterhelper.NewFactory(
3434
typeStr,
3535
createDefaultConfig,
36-
exporterhelper.WithTraces(createTraceExporter),
36+
exporterhelper.WithTraces(createTracesExporter),
3737
exporterhelper.WithMetrics(createMetricsExporter),
3838
exporterhelper.WithLogs(createLogsExporter))
3939
}
@@ -44,7 +44,7 @@ func createDefaultConfig() config.Exporter {
4444
}
4545
}
4646

47-
func createTraceExporter(
47+
func createTracesExporter(
4848
_ context.Context,
4949
_ component.ExporterCreateParams,
5050
cfg config.Exporter,

exporter/fileexporter/factory_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func TestCreateMetricsExporter(t *testing.T) {
4242
require.Nil(t, exp)
4343
}
4444

45-
func TestCreateTraceExporter(t *testing.T) {
45+
func TestCreateTracesExporter(t *testing.T) {
4646
cfg := createDefaultConfig()
47-
exp, err := createTraceExporter(
47+
exp, err := createTracesExporter(
4848
context.Background(),
4949
component.ExporterCreateParams{Logger: zap.NewNop()},
5050
cfg)

0 commit comments

Comments
 (0)