You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
debug('retrying with %d ms',this.baseRetryInterval)
227
-
returnthis.baseRetryInterval
228
-
}
229
-
230
223
CollectorApi.prototype.getService=function(cb){
231
-
debug('getting service id from the trace servers')
232
-
233
224
varopts=url.parse(this.COLLECTOR_API_SERVICE)
234
225
var_this=this
235
226
cb=cb||function(){}
@@ -272,42 +263,49 @@ CollectorApi.prototype.getService = function (cb) {
272
263
res.pipe(bl(function(err,resBuffer){
273
264
varresponse
274
265
266
+
varretryInterval=_this.baseRetryInterval
267
+
275
268
if(err){
276
-
debug('There was an error when connecting to the Trace API, retrying',err)
269
+
debug('#getService','[Error]',err)
277
270
returnsetTimeout(function(){
271
+
debug('#getService','Retrying with %d ms',retryInterval)
278
272
_this.getService()
279
-
},_this._getRetryInterval())
273
+
},retryInterval)
280
274
}
281
275
282
276
varresText=resBuffer.toString('utf8')
283
277
284
-
debug('raw response from trace servers: ',resText)
285
278
if(res.statusCode===401){
279
+
debug('#getService','[Error] Api key rejected')
286
280
returnconsole.error('error: [trace]','Trace API key is rejected - are you sure you are using the right one?')
287
281
}
288
282
if(res.statusCode>399){
283
+
debug('#getService','[Error] Service responded with',res.statusCode)
284
+
console.log(setTimeout)
285
+
console.log(retryInterval)
289
286
returnsetTimeout(function(){
287
+
debug('#getService','Retrying with %d ms',retryInterval)
288
+
console.log('adsfsadf')
290
289
_this.getService(cb)
291
-
},_this._getRetryInterval())
290
+
},retryInterval)
292
291
}
293
292
294
293
try{
295
294
response=JSON.parse(resText)
296
295
}catch(ex){
297
-
debug('Error parsing JSON:',ex)
298
-
returndebug(ex)
296
+
return
299
297
}
300
298
301
299
_this.serviceKey=response.key
302
300
cb(null,response.key)
303
301
}))
304
302
})
305
303
306
-
debug('getting serviceKey with payload:',payload)
304
+
debug('#getService','Sending request')
307
305
308
306
req.on('error',function(error){
309
307
console.error('error: [trace]','There was an error connecting to the Trace servers to get the service key. Make sure your servers can reach',opts.hostname)
310
-
debug('error connecting to the Trace servers',error)
0 commit comments