@@ -9,6 +9,8 @@ const { promisify } = require('util');
9
9
const gitconfig = require ( 'gitconfiglocal' ) ;
10
10
const { spawn, execSync } = require ( 'child_process' ) ;
11
11
const glob = require ( 'glob' ) ;
12
+ const util = require ( 'util' ) ;
13
+
12
14
const { runOptions } = require ( '../../helpers/runnerArgs' )
13
15
14
16
const pGitconfig = promisify ( gitconfig ) ;
@@ -38,6 +40,13 @@ exports.pending_test_uploads = {
38
40
count : 0
39
41
} ;
40
42
43
+ exports . debugOnConsole = ( text ) => {
44
+ if ( ( process . env . BROWSERSTACK_OBSERVABILITY_DEBUG + '' ) === "true" ||
45
+ ( process . env . BROWSERSTACK_OBSERVABILITY_DEBUG + '' ) === "1" ) {
46
+ consoleHolder . log ( `[ OBSERVABILITY ] ${ text } ` ) ;
47
+ }
48
+ }
49
+
41
50
exports . debug = ( text , shouldReport = false , throwable = null ) => {
42
51
if ( process . env . BROWSERSTACK_OBSERVABILITY_DEBUG === "true" || process . env . BROWSERSTACK_OBSERVABILITY_DEBUG === "1" ) {
43
52
logger . info ( `[ OBSERVABILITY ] ${ text } ` ) ;
@@ -475,14 +484,18 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => {
475
484
} ;
476
485
477
486
try {
487
+ const eventsUuids = data . map ( eventData => `${ eventData . event_type } :${ eventData . test_run ? eventData . test_run . uuid : ( eventData . hook_run ? eventData . hook_run . uuid : null ) } ` ) . join ( ', ' ) ;
488
+ exports . debugOnConsole ( `[Request Batch Send] for events:uuids ${ eventsUuids } ` ) ;
478
489
const response = await nodeRequest ( 'POST' , eventUrl , data , config ) ;
490
+ exports . debugOnConsole ( `[Request Batch Response] for events:uuids ${ eventsUuids } ` ) ;
479
491
if ( response . data . error ) {
480
492
throw ( { message : response . data . error } ) ;
481
493
} else {
482
494
exports . debug ( `${ kind } event successfull!` )
483
495
exports . pending_test_uploads . count = Math . max ( 0 , exports . pending_test_uploads . count - data . length ) ;
484
496
}
485
497
} catch ( error ) {
498
+ exports . debugOnConsole ( `[Request Error] Error in sending request ${ util . format ( error ) } ` ) ;
486
499
if ( error . response ) {
487
500
exports . debug ( `EXCEPTION IN ${ kind } REQUEST TO TEST OBSERVABILITY : ${ error . response . status } ${ error . response . statusText } ${ JSON . stringify ( error . response . data ) } ` , true , error ) ;
488
501
} else {
@@ -522,6 +535,7 @@ exports.uploadEventData = async (eventData, run=0) => {
522
535
523
536
exports . requestQueueHandler . start ( ) ;
524
537
const { shouldProceed, proceedWithData, proceedWithUrl } = exports . requestQueueHandler . add ( eventData ) ;
538
+ exports . debugOnConsole ( `[Request Queue] ${ eventData . event_type } with uuid ${ eventData . test_run ? eventData . test_run . uuid : ( eventData . hook_run ? eventData . hook_run . uuid : null ) } is added` )
525
539
if ( ! shouldProceed ) {
526
540
return ;
527
541
} else if ( proceedWithData ) {
@@ -538,7 +552,10 @@ exports.uploadEventData = async (eventData, run=0) => {
538
552
} ;
539
553
540
554
try {
555
+ const eventsUuids = data . map ( eventData => `${ eventData . event_type } :${ eventData . test_run ? eventData . test_run . uuid : ( eventData . hook_run ? eventData . hook_run . uuid : null ) } ` ) . join ( ', ' ) ;
556
+ exports . debugOnConsole ( `[Request Send] for events:uuids ${ eventsUuids } ` ) ;
541
557
const response = await nodeRequest ( 'POST' , event_api_url , data , config ) ;
558
+ exports . debugOnConsole ( `[Request Repsonse] ${ util . format ( response . data ) } for events:uuids ${ eventsUuids } ` )
542
559
if ( response . data . error ) {
543
560
throw ( { message : response . data . error } ) ;
544
561
} else {
@@ -550,6 +567,7 @@ exports.uploadEventData = async (eventData, run=0) => {
550
567
} ;
551
568
}
552
569
} catch ( error ) {
570
+ exports . debugOnConsole ( `[Request Error] Error in sending request ${ util . format ( error ) } ` ) ;
553
571
if ( error . response ) {
554
572
exports . debug ( `EXCEPTION IN ${ event_api_url !== exports . requestQueueHandler . eventUrl ? log_tag : 'Batch-Queue' } REQUEST TO TEST OBSERVABILITY : ${ error . response . status } ${ error . response . statusText } ${ JSON . stringify ( error . response . data ) } ` , true , error ) ;
555
573
} else {
0 commit comments