@@ -148,11 +148,6 @@ function httpWrapper(wrappedFunction) {
148
148
const { url, options, callback } = parseArgs ( a , b , c ) ;
149
149
const chunks = [ ] ;
150
150
151
- if ( callback && callback . __epsagonCallback ) { // eslint-disable-line no-underscore-dangle
152
- // we are already tracing this request. can happen in
153
- // https->http cases
154
- return wrappedFunction . apply ( this , [ a , b , c ] ) ;
155
- }
156
151
let clientRequest = null ;
157
152
try {
158
153
let parsedUrl = url ;
@@ -169,8 +164,18 @@ function httpWrapper(wrappedFunction) {
169
164
( options && options . uri && options . uri . hostname ) ||
170
165
'localhost'
171
166
) ;
167
+ utils . debugLog ( `[http] captured call ${ hostname } ` ) ;
168
+
169
+ // eslint-disable-next-line no-underscore-dangle
170
+ if ( callback && callback . __epsagonCallback ) {
171
+ // we are already tracing this request. can happen in
172
+ // https->http cases
173
+ utils . debugLog ( `[http] filtered patched callback ${ hostname } ` ) ;
174
+ return wrappedFunction . apply ( this , [ a , b , c ] ) ;
175
+ }
176
+
172
177
// Capture the port if provided and is different than standard 80 and 443
173
- if ( options . port && ! [ '80' , '443' ] . includes ( options . port ) ) {
178
+ if ( options . port && ! [ '80' , '443' , 80 , 443 ] . includes ( options . port ) ) {
174
179
hostname = `${ hostname } :${ options . port } ` ;
175
180
}
176
181
@@ -191,11 +196,11 @@ function httpWrapper(wrappedFunction) {
191
196
) ;
192
197
193
198
if ( isBlacklistURL ( hostname , URL_BLACKLIST , path ) || isURLIgnoredByUser ( hostname ) ) {
194
- utils . debugLog ( `filtered blacklist hostname ${ hostname } ` ) ;
199
+ utils . debugLog ( `[http] filtered ignored hostname ${ hostname } ` ) ;
195
200
return wrappedFunction . apply ( this , [ a , b , c ] ) ;
196
201
}
197
202
if ( isBlacklistHeader ( headers , USER_AGENTS_BLACKLIST ) ) {
198
- utils . debugLog ( 'filtered blacklist headers headers' ) ;
203
+ utils . debugLog ( '[http] filtered ignored headers' ) ;
199
204
return wrappedFunction . apply ( this , [ a , b , c ] ) ;
200
205
}
201
206
@@ -277,6 +282,7 @@ function httpWrapper(wrappedFunction) {
277
282
}
278
283
279
284
const patchedCallback = ( res ) => {
285
+ utils . debugLog ( `[http] patched callback called for ${ hostname } ` ) ;
280
286
const metadataFields = { } ;
281
287
if ( 'x-openwhisk-activation-id' in res . headers ) {
282
288
// This field is used to identify activation ID from 'OpenWhisk'
@@ -316,6 +322,7 @@ function httpWrapper(wrappedFunction) {
316
322
clientRequest = wrappedFunction . apply (
317
323
this , buildParams ( url , options , patchedCallback )
318
324
) ;
325
+ utils . debugLog ( `[http] request sent ${ hostname } ` ) ;
319
326
320
327
if (
321
328
options &&
@@ -425,6 +432,7 @@ function httpWrapper(wrappedFunction) {
425
432
} ;
426
433
427
434
clientRequest . on ( 'response' , ( res ) => {
435
+ utils . debugLog ( `[http] response arrived for ${ hostname } ` ) ;
428
436
// Listening to data only if options.epsagonSkipResponseData!=true or no options
429
437
if ( ! checkIfOmitData ( ) ) {
430
438
res . on ( 'data' , chunk => addChunk ( chunk , chunks ) ) ;
@@ -440,14 +448,17 @@ function httpWrapper(wrappedFunction) {
440
448
} ) ;
441
449
442
450
tracer . addEvent ( httpEvent , responsePromise ) ;
451
+ utils . debugLog ( `[http] event added ${ hostname } ` ) ;
443
452
} catch ( error ) {
444
453
tracer . addException ( error ) ;
445
454
}
446
455
447
456
if ( ! clientRequest ) {
457
+ utils . debugLog ( '[http] not client request set' ) ;
448
458
clientRequest = wrappedFunction . apply ( this , [ a , b , c ] ) ;
449
459
}
450
460
461
+ utils . debugLog ( '[http] done handling call' ) ;
451
462
return clientRequest ;
452
463
} ;
453
464
}
0 commit comments