@@ -20,9 +20,7 @@ function CollectorApi (options) {
2020 this . processId = options . processId
2121 this . hostname = options . hostname
2222 this . serviceName = options . serviceName
23- this . baseRetryInterval = 100
24- this . retryCount = 0
25- this . retryLimit = 13
23+ this . baseRetryInterval = 1000 * 60 * 30 // 30 minutes
2624 this . serviceKey = null
2725}
2826
@@ -98,9 +96,8 @@ CollectorApi.prototype.sendSamples = function (data) {
9896}
9997
10098CollectorApi . prototype . _getRetryInterval = function ( ) {
101- var retryInterval = Math . pow ( 2 , this . retryCount ) * this . baseRetryInterval
102- debug ( 'retrying with %d ms' , retryInterval )
103- return retryInterval
99+ debug ( 'retrying with %d ms' , this . baseRetryInterval )
100+ return this . baseRetryInterval
104101}
105102
106103CollectorApi . prototype . getService = function ( cb ) {
@@ -113,7 +110,6 @@ CollectorApi.prototype.getService = function (cb) {
113110 var payload = JSON . stringify ( {
114111 name : _this . serviceName
115112 } )
116-
117113 var req = https . request ( {
118114 hostname : opts . hostname ,
119115 port : opts . port ,
@@ -132,12 +128,9 @@ CollectorApi.prototype.getService = function (cb) {
132128
133129 if ( err ) {
134130 debug ( 'There was an error when connecting to the Trace API, retrying' , err )
135- if ( ++ _this . retryCount < _this . retryLimit ) {
136- return setTimeout ( function ( ) {
137- _this . getService ( )
138- } , _this . _getRetryInterval ( ) )
139- }
140- return debug ( 'The trace collector-api is currently unavailable' , err )
131+ return setTimeout ( function ( ) {
132+ _this . getService ( )
133+ } , _this . _getRetryInterval ( ) )
141134 }
142135
143136 var resText = resBuffer . toString ( 'utf8' )
@@ -147,13 +140,9 @@ CollectorApi.prototype.getService = function (cb) {
147140 return console . error ( format ( '%s trace: error: %s' , new Date ( ) , 'TRACE_API_KEY got rejected - are you sure you are using the right one?' ) )
148141 }
149142 if ( res . statusCode > 399 ) {
150- if ( ++ _this . retryCount < _this . retryLimit ) {
151- return setTimeout ( function ( ) {
152- _this . getService ( cb )
153- } , _this . _getRetryInterval ( ) )
154- }
155-
156- return cb ( new Error ( 'The trace collector-api is currently unavailable' ) )
143+ return setTimeout ( function ( ) {
144+ _this . getService ( cb )
145+ } , _this . _getRetryInterval ( ) )
157146 }
158147
159148 try {
0 commit comments