@@ -103,7 +103,7 @@ CollectorApi.prototype._send = function (destinationUrl, data, callback, options
103103 res . pipe ( bl ( function ( err , result ) {
104104 if ( err ) {
105105 debug ( '#_send' , '[Error]' , err )
106- return
106+ return callback ( err )
107107 }
108108 callback ( null , result )
109109 } ) )
@@ -126,37 +126,39 @@ CollectorApi.prototype._send = function (destinationUrl, data, callback, options
126126 }
127127}
128128
129- CollectorApi . prototype . sendRpmMetrics = function ( data ) {
129+ CollectorApi . prototype . sendRpmMetrics = function ( data , callback ) {
130+ callback = callback || function ( ) { }
130131 if ( ! isNumber ( this . serviceKey ) ) {
131132 debug ( '#sendRpmMetrics' , '[Error] Service key not present, cannot send rpm metrics' )
132- return
133+ return callback ( new Error ( 'serviceKey is missing' ) )
133134 }
134135
135136 var url = util . format ( this . COLLECTOR_API_RPM_METRICS , this . serviceKey )
136- this . _send ( url , this . _withInstanceInfo ( data ) )
137+ this . _send ( url , this . _withInstanceInfo ( data ) , callback )
137138}
138139
139140CollectorApi . prototype . ping = function ( ) {
140141 if ( ! isNumber ( this . serviceKey ) ) {
141142 debug ( '#ping' , '[Error] Service key not present, cannot do healthcheck' )
142- return
143143 }
144144
145145 var url = util . format ( this . COLLECTOR_API_HEALTHCHECK , this . serviceKey )
146146 this . _send ( url , this . _withInstanceInfo ( { } ) )
147147}
148148
149- CollectorApi . prototype . sendApmMetrics = function ( data ) {
149+ CollectorApi . prototype . sendApmMetrics = function ( data , callback ) {
150+ callback = callback || function ( ) { }
150151 if ( ! isNumber ( this . serviceKey ) ) {
151152 debug ( '#sendApmMetrics' , '[Error] Service key not present, cannot send metrics' )
152- return
153+ return callback ( new Error ( 'serviceKey is missing' ) )
153154 }
154155
155156 var url = util . format ( this . COLLECTOR_API_METRICS , this . serviceKey )
156- this . _send ( url , this . _withInstanceInfo ( data ) )
157+ this . _send ( url , this . _withInstanceInfo ( data ) , callback )
157158}
158159
159160CollectorApi . prototype . sendMemorySnapshot = function ( data , callback ) {
161+ callback = callback || function ( ) { }
160162 if ( ! isNumber ( this . serviceKey ) ) {
161163 debug ( '#sendMemorySnapshot' , '[Error] Service key not present, cannot send heapdump' )
162164 return callback ( new Error ( 'serviceKey is missing' ) )
@@ -167,6 +169,7 @@ CollectorApi.prototype.sendMemorySnapshot = function (data, callback) {
167169}
168170
169171CollectorApi . prototype . sendCpuProfile = function ( data , callback ) {
172+ callback = callback || function ( ) { }
170173 if ( ! isNumber ( this . serviceKey ) ) {
171174 debug ( '#sendCpuProfile' , '[Error] Service key not present, cannot send cpu profile' )
172175 return callback ( new Error ( 'serviceKey is missing' ) )
@@ -176,33 +179,36 @@ CollectorApi.prototype.sendCpuProfile = function (data, callback) {
176179 this . _send ( url , this . _withInstanceInfo ( data ) , callback )
177180}
178181
179- CollectorApi . prototype . sendExternalEdgeMetrics = function ( data ) {
182+ CollectorApi . prototype . sendExternalEdgeMetrics = function ( data , callback ) {
183+ callback = callback || function ( ) { }
180184 if ( ! isNumber ( this . serviceKey ) ) {
181185 debug ( '#sendExternalEdgeMetrics' , '[Error] Service key not present, cannot send metrics' )
182- return
186+ return callback ( new Error ( 'serviceKey is missing' ) )
183187 }
184188
185189 var url = util . format ( this . COLLECTOR_API_EXTERNAL_EDGE_METRICS , this . serviceKey )
186- this . _send ( url , this . _withInstanceInfo ( data ) )
190+ this . _send ( url , this . _withInstanceInfo ( data ) , callback )
187191}
188192
189- CollectorApi . prototype . sendIncomingEdgeMetrics = function ( data ) {
193+ CollectorApi . prototype . sendIncomingEdgeMetrics = function ( data , callback ) {
194+ callback = callback || function ( ) { }
190195 if ( ! isNumber ( this . serviceKey ) ) {
191196 debug ( '#sendIncomingEdgeMetrics' , '[Error] Service key not present, cannot send metrics' )
192- return
197+ return callback ( new Error ( 'serviceKey is missing' ) )
193198 }
194199
195200 var url = util . format ( this . COLLECTOR_API_INCOMING_EDGE_METRICS , this . serviceKey )
196201 this . _send ( url , this . _withInstanceInfo ( {
197202 timestamp : ( new Date ( ) ) . toISOString ( ) ,
198203 data : data
199- } ) )
204+ } ) , callback )
200205}
201206
202207CollectorApi . prototype . getUpdates = function ( data , callback ) {
208+ callback = callback || function ( ) { }
203209 if ( ! isNumber ( this . serviceKey ) ) {
204210 debug ( '#getUpdates' , '[Error] Service key not present, cannot get updates' )
205- return
211+ return callback ( new Error ( 'serviceKey is missing' ) )
206212 }
207213
208214 var url = util . format ( this . COLLECTOR_API_CONTROL , this . serviceKey )
@@ -222,17 +228,18 @@ CollectorApi.prototype.getUpdates = function (data, callback) {
222228 } )
223229}
224230
225- CollectorApi . prototype . sendCustomMetrics = function ( data ) {
231+ CollectorApi . prototype . sendCustomMetrics = function ( data , callback ) {
232+ callback = callback || function ( ) { }
226233 if ( ! isNumber ( this . serviceKey ) ) {
227234 debug ( '#sendCustomMetrics' , '[Error] Service key not present, cannot send metrics' )
228- return
235+ return callback ( new Error ( 'serviceKey is missing' ) )
229236 }
230237
231238 var url = util . format ( this . COLLECTOR_API_CUSTOM_METRICS , this . serviceKey )
232239 this . _send ( url , this . _withInstanceInfo ( {
233240 timestamp : ( new Date ( ) ) . toISOString ( ) ,
234241 data : data
235- } ) )
242+ } ) , callback )
236243}
237244
238245CollectorApi . prototype . sendDependencies = function ( dependencies ) {
0 commit comments