@@ -34,15 +34,15 @@ import (
34
34
)
35
35
36
36
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"
39
39
fakeTraceParentSpanName = "fake_trace_parent_span_name"
40
40
)
41
41
42
42
var (
43
- fakeTraceExporterConfig = & config.ExporterSettings {
44
- TypeVal : fakeTraceExporterType ,
45
- NameVal : fakeTraceExporterName ,
43
+ fakeTracesExporterConfig = & config.ExporterSettings {
44
+ TypeVal : fakeTracesExporterType ,
45
+ NameVal : fakeTracesExporterName ,
46
46
}
47
47
)
48
48
@@ -53,108 +53,108 @@ func TestTracesRequest(t *testing.T) {
53
53
assert .EqualValues (t , newTracesRequest (context .Background (), testdata .GenerateTraceDataEmpty (), nil ), mr .onError (traceErr ))
54
54
}
55
55
56
- type testOCTraceExporter struct {
56
+ type testOCTracesExporter struct {
57
57
mu sync.Mutex
58
58
spanData []* trace.SpanData
59
59
}
60
60
61
- func (tote * testOCTraceExporter ) ExportSpan (sd * trace.SpanData ) {
61
+ func (tote * testOCTracesExporter ) ExportSpan (sd * trace.SpanData ) {
62
62
tote .mu .Lock ()
63
63
defer tote .mu .Unlock ()
64
64
65
65
tote .spanData = append (tote .spanData , sd )
66
66
}
67
67
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 ))
70
70
require .Nil (t , te )
71
71
require .Equal (t , errNilConfig , err )
72
72
}
73
73
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 ))
76
76
require .Nil (t , te )
77
77
require .Equal (t , errNilLogger , err )
78
78
}
79
79
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 )
82
82
require .Nil (t , te )
83
83
require .Equal (t , errNilPushTraceData , err )
84
84
}
85
85
86
- func TestTraceExporter_Default (t * testing.T ) {
86
+ func TestTracesExporter_Default (t * testing.T ) {
87
87
td := pdata .NewTraces ()
88
- te , err := NewTraceExporter ( fakeTraceExporterConfig , zap .NewNop (), newTraceDataPusher (nil ))
88
+ te , err := NewTracesExporter ( fakeTracesExporterConfig , zap .NewNop (), newTraceDataPusher (nil ))
89
89
assert .NotNil (t , te )
90
90
assert .NoError (t , err )
91
91
92
92
assert .Nil (t , te .ConsumeTraces (context .Background (), td ))
93
93
assert .Nil (t , te .Shutdown (context .Background ()))
94
94
}
95
95
96
- func TestTraceExporter_Default_ReturnError (t * testing.T ) {
96
+ func TestTracesExporter_Default_ReturnError (t * testing.T ) {
97
97
td := pdata .NewTraces ()
98
98
want := errors .New ("my_error" )
99
- te , err := NewTraceExporter ( fakeTraceExporterConfig , zap .NewNop (), newTraceDataPusher (want ))
99
+ te , err := NewTracesExporter ( fakeTracesExporterConfig , zap .NewNop (), newTraceDataPusher (want ))
100
100
require .Nil (t , err )
101
101
require .NotNil (t , te )
102
102
103
103
err = te .ConsumeTraces (context .Background (), td )
104
104
require .Equal (t , want , err )
105
105
}
106
106
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 ))
109
109
require .Nil (t , err )
110
110
require .NotNil (t , te )
111
111
112
- checkRecordedMetricsForTraceExporter (t , te , nil )
112
+ checkRecordedMetricsForTracesExporter (t , te , nil )
113
113
}
114
114
115
- func TestTraceExporter_WithRecordMetrics_ReturnError (t * testing.T ) {
115
+ func TestTracesExporter_WithRecordMetrics_ReturnError (t * testing.T ) {
116
116
want := errors .New ("my_error" )
117
- te , err := NewTraceExporter ( fakeTraceExporterConfig , zap .NewNop (), newTraceDataPusher (want ))
117
+ te , err := NewTracesExporter ( fakeTracesExporterConfig , zap .NewNop (), newTraceDataPusher (want ))
118
118
require .Nil (t , err )
119
119
require .NotNil (t , te )
120
120
121
- checkRecordedMetricsForTraceExporter (t , te , want )
121
+ checkRecordedMetricsForTracesExporter (t , te , want )
122
122
}
123
123
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 ))
126
126
require .Nil (t , err )
127
127
require .NotNil (t , te )
128
128
129
- checkWrapSpanForTraceExporter (t , te , nil , 1 )
129
+ checkWrapSpanForTracesExporter (t , te , nil , 1 )
130
130
}
131
131
132
- func TestTraceExporter_WithSpan_ReturnError (t * testing.T ) {
132
+ func TestTracesExporter_WithSpan_ReturnError (t * testing.T ) {
133
133
want := errors .New ("my_error" )
134
- te , err := NewTraceExporter ( fakeTraceExporterConfig , zap .NewNop (), newTraceDataPusher (want ))
134
+ te , err := NewTracesExporter ( fakeTracesExporterConfig , zap .NewNop (), newTraceDataPusher (want ))
135
135
require .Nil (t , err )
136
136
require .NotNil (t , te )
137
137
138
- checkWrapSpanForTraceExporter (t , te , want , 1 )
138
+ checkWrapSpanForTracesExporter (t , te , want , 1 )
139
139
}
140
140
141
- func TestTraceExporter_WithShutdown (t * testing.T ) {
141
+ func TestTracesExporter_WithShutdown (t * testing.T ) {
142
142
shutdownCalled := false
143
143
shutdown := func (context.Context ) error { shutdownCalled = true ; return nil }
144
144
145
- te , err := NewTraceExporter ( fakeTraceExporterConfig , zap .NewNop (), newTraceDataPusher (nil ), WithShutdown (shutdown ))
145
+ te , err := NewTracesExporter ( fakeTracesExporterConfig , zap .NewNop (), newTraceDataPusher (nil ), WithShutdown (shutdown ))
146
146
assert .NotNil (t , te )
147
147
assert .NoError (t , err )
148
148
149
149
assert .Nil (t , te .Shutdown (context .Background ()))
150
150
assert .True (t , shutdownCalled )
151
151
}
152
152
153
- func TestTraceExporter_WithShutdown_ReturnError (t * testing.T ) {
153
+ func TestTracesExporter_WithShutdown_ReturnError (t * testing.T ) {
154
154
want := errors .New ("my_error" )
155
155
shutdownErr := func (context.Context ) error { return want }
156
156
157
- te , err := NewTraceExporter ( fakeTraceExporterConfig , zap .NewNop (), newTraceDataPusher (nil ), WithShutdown (shutdownErr ))
157
+ te , err := NewTracesExporter ( fakeTracesExporterConfig , zap .NewNop (), newTraceDataPusher (nil ), WithShutdown (shutdownErr ))
158
158
assert .NotNil (t , te )
159
159
assert .NoError (t , err )
160
160
@@ -167,7 +167,7 @@ func newTraceDataPusher(retError error) PushTraces {
167
167
}
168
168
}
169
169
170
- func checkRecordedMetricsForTraceExporter (t * testing.T , te component.TracesExporter , wantError error ) {
170
+ func checkRecordedMetricsForTracesExporter (t * testing.T , te component.TracesExporter , wantError error ) {
171
171
doneFn , err := obsreporttest .SetupRecordedMetricsTest ()
172
172
require .NoError (t , err )
173
173
defer doneFn ()
@@ -180,9 +180,9 @@ func checkRecordedMetricsForTraceExporter(t *testing.T, te component.TracesExpor
180
180
181
181
// TODO: When the new metrics correctly count partial dropped fix this.
182
182
if wantError != nil {
183
- obsreporttest .CheckExporterTracesViews (t , fakeTraceExporterName , 0 , int64 (numBatches * td .SpanCount ()))
183
+ obsreporttest .CheckExporterTracesViews (t , fakeTracesExporterName , 0 , int64 (numBatches * td .SpanCount ()))
184
184
} else {
185
- obsreporttest .CheckExporterTracesViews (t , fakeTraceExporterName , int64 (numBatches * td .SpanCount ()), 0 )
185
+ obsreporttest .CheckExporterTracesViews (t , fakeTracesExporterName , int64 (numBatches * td .SpanCount ()), 0 )
186
186
}
187
187
}
188
188
@@ -199,8 +199,8 @@ func generateTraceTraffic(t *testing.T, te component.TracesExporter, numRequests
199
199
}
200
200
}
201
201
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 )
204
204
trace .RegisterExporter (ocSpansSaver )
205
205
defer trace .UnregisterExporter (ocSpansSaver )
206
206
0 commit comments