@@ -22,6 +22,7 @@ import (
22
22
"github.com/stretchr/testify/assert"
23
23
"go.uber.org/zap"
24
24
25
+ "github.com/open-telemetry/opentelemetry-collector/component"
25
26
"github.com/open-telemetry/opentelemetry-collector/config"
26
27
"github.com/open-telemetry/opentelemetry-collector/config/configcheck"
27
28
"github.com/open-telemetry/opentelemetry-collector/config/configerror"
@@ -48,11 +49,12 @@ func TestCreateReceiver(t *testing.T) {
48
49
// have to enable at least one protocol for the jaeger receiver to be created
49
50
cfg .(* Config ).Protocols [protoGRPC ], _ = defaultsForProtocol (protoGRPC )
50
51
51
- tReceiver , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
52
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
53
+ tReceiver , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
52
54
assert .NoError (t , err , "receiver creation failed" )
53
55
assert .NotNil (t , tReceiver , "receiver creation failed" )
54
56
55
- mReceiver , err := factory .CreateMetricsReceiver (zap . NewNop () , cfg , nil )
57
+ mReceiver , err := factory .CreateMetricsReceiver (context . Background (), params , cfg , nil )
56
58
assert .Equal (t , err , configerror .ErrDataTypeIsNotSupported )
57
59
assert .Nil (t , mReceiver )
58
60
}
@@ -64,7 +66,8 @@ func TestCreateDefaultGRPCEndpoint(t *testing.T) {
64
66
rCfg := cfg .(* Config )
65
67
66
68
rCfg .Protocols [protoGRPC ], _ = defaultsForProtocol (protoGRPC )
67
- r , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
69
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
70
+ r , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
68
71
69
72
assert .NoError (t , err , "unexpected error creating receiver" )
70
73
assert .Equal (t , 14250 , r .(* jReceiver ).config .CollectorGRPCPort , "grpc port should be default" )
@@ -77,14 +80,15 @@ func TestCreateTLSGPRCEndpoint(t *testing.T) {
77
80
78
81
rCfg .Protocols [protoGRPC ], _ = defaultsForProtocol (protoGRPC )
79
82
rCfg .Protocols [protoGRPC ].TLSCredentials = & receiver.TLSCredentials {}
80
- _ , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
83
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
84
+ _ , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
81
85
assert .Error (t , err , "tls-enabled receiver creation with no credentials must fail" )
82
86
83
87
rCfg .Protocols [protoGRPC ].TLSCredentials = & receiver.TLSCredentials {
84
88
CertFile : "./testdata/certificate.pem" ,
85
89
KeyFile : "./testdata/key.pem" ,
86
90
}
87
- _ , err = factory .CreateTraceReceiver (context .Background (), zap . NewNop () , cfg , nil )
91
+ _ , err = factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
88
92
assert .NoError (t , err , "tls-enabled receiver creation failed" )
89
93
}
90
94
@@ -94,7 +98,8 @@ func TestCreateInvalidHTTPEndpoint(t *testing.T) {
94
98
rCfg := cfg .(* Config )
95
99
96
100
rCfg .Protocols [protoThriftHTTP ], _ = defaultsForProtocol (protoThriftHTTP )
97
- r , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
101
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
102
+ r , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
98
103
99
104
assert .NoError (t , err , "unexpected error creating receiver" )
100
105
assert .Equal (t , 14268 , r .(* jReceiver ).config .CollectorHTTPPort , "http port should be default" )
@@ -106,7 +111,8 @@ func TestCreateInvalidThriftBinaryEndpoint(t *testing.T) {
106
111
rCfg := cfg .(* Config )
107
112
108
113
rCfg .Protocols [protoThriftBinary ], _ = defaultsForProtocol (protoThriftBinary )
109
- r , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
114
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
115
+ r , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
110
116
111
117
assert .NoError (t , err , "unexpected error creating receiver" )
112
118
assert .Equal (t , 6832 , r .(* jReceiver ).config .AgentBinaryThriftPort , "thrift port should be default" )
@@ -118,7 +124,8 @@ func TestCreateInvalidThriftCompactEndpoint(t *testing.T) {
118
124
rCfg := cfg .(* Config )
119
125
120
126
rCfg .Protocols [protoThriftCompact ], _ = defaultsForProtocol (protoThriftCompact )
121
- r , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
127
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
128
+ r , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
122
129
123
130
assert .NoError (t , err , "unexpected error creating receiver" )
124
131
assert .Equal (t , 6831 , r .(* jReceiver ).config .AgentCompactThriftPort , "thrift port should be default" )
@@ -131,7 +138,8 @@ func TestDefaultAgentRemoteSamplingEndpointAndPort(t *testing.T) {
131
138
132
139
rCfg .Protocols [protoThriftCompact ], _ = defaultsForProtocol (protoThriftCompact )
133
140
rCfg .RemoteSampling = & RemoteSamplingConfig {}
134
- r , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
141
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
142
+ r , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
135
143
136
144
assert .NoError (t , err , "create trace receiver should not error" )
137
145
assert .Equal (t , defaultGRPCBindEndpoint , r .(* jReceiver ).config .RemoteSamplingEndpoint )
@@ -148,7 +156,8 @@ func TestAgentRemoteSamplingEndpoint(t *testing.T) {
148
156
rCfg .RemoteSampling = & RemoteSamplingConfig {
149
157
FetchEndpoint : endpoint ,
150
158
}
151
- r , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
159
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
160
+ r , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
152
161
153
162
assert .NoError (t , err , "create trace receiver should not error" )
154
163
assert .Equal (t , endpoint , r .(* jReceiver ).config .RemoteSamplingEndpoint )
@@ -165,7 +174,8 @@ func TestCreateNoPort(t *testing.T) {
165
174
Endpoint : "localhost:" ,
166
175
},
167
176
}
168
- _ , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
177
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
178
+ _ , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
169
179
assert .Error (t , err , "receiver creation with no port number must fail" )
170
180
}
171
181
@@ -179,7 +189,8 @@ func TestCreateLargePort(t *testing.T) {
179
189
Endpoint : "localhost:65536" ,
180
190
},
181
191
}
182
- _ , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
192
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
193
+ _ , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
183
194
assert .Error (t , err , "receiver creation with too large port number must fail" )
184
195
}
185
196
@@ -193,7 +204,8 @@ func TestCreateInvalidHost(t *testing.T) {
193
204
Endpoint : "1234" ,
194
205
},
195
206
}
196
- _ , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
207
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
208
+ _ , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
197
209
assert .Error (t , err , "receiver creation with bad hostname must fail" )
198
210
}
199
211
@@ -204,7 +216,8 @@ func TestCreateNoProtocols(t *testing.T) {
204
216
205
217
rCfg .Protocols = make (map [string ]* receiver.SecureReceiverSettings )
206
218
207
- _ , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
219
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
220
+ _ , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
208
221
assert .Error (t , err , "receiver creation with no protocols must fail" )
209
222
}
210
223
@@ -219,7 +232,8 @@ func TestThriftBinaryBadPort(t *testing.T) {
219
232
},
220
233
}
221
234
222
- _ , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
235
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
236
+ _ , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
223
237
assert .Error (t , err , "receiver creation with a bad thrift binary port must fail" )
224
238
}
225
239
@@ -234,7 +248,8 @@ func TestThriftCompactBadPort(t *testing.T) {
234
248
},
235
249
}
236
250
237
- _ , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
251
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
252
+ _ , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
238
253
assert .Error (t , err , "receiver creation with a bad thrift compact port must fail" )
239
254
}
240
255
@@ -252,7 +267,8 @@ func TestRemoteSamplingConfigPropagation(t *testing.T) {
252
267
HostEndpoint : fmt .Sprintf ("localhost:%d" , hostPort ),
253
268
StrategyFile : strategyFile ,
254
269
}
255
- r , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
270
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
271
+ r , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
256
272
257
273
assert .NoError (t , err , "create trace receiver should not error" )
258
274
assert .Equal (t , endpoint , r .(* jReceiver ).config .RemoteSamplingEndpoint )
@@ -270,7 +286,8 @@ func TestRemoteSamplingFileRequiresGRPC(t *testing.T) {
270
286
rCfg .RemoteSampling = & RemoteSamplingConfig {
271
287
StrategyFile : strategyFile ,
272
288
}
273
- _ , err := factory .CreateTraceReceiver (context .Background (), zap .NewNop (), cfg , nil )
289
+ params := component.ReceiverCreateParams {Logger : zap .NewNop ()}
290
+ _ , err := factory .CreateTraceReceiver (context .Background (), params , cfg , nil )
274
291
275
292
assert .Error (t , err , "create trace receiver should error" )
276
293
}
0 commit comments