@@ -46,6 +46,8 @@ const {
4646 TEST_RETRY_REASON_TYPES ,
4747 getPullRequestDiff,
4848 getModifiedFilesFromDiff,
49+ getSessionRequestErrorTags,
50+ DD_CI_LIBRARY_CONFIGURATION_ERROR ,
4951 TEST_IS_MODIFIED ,
5052 getPullRequestBaseBranch,
5153} = require ( '../../dd-trace/src/plugins/util/test' )
@@ -317,10 +319,15 @@ class CypressPlugin {
317319 this . testEnvironmentMetadata [ DD_TEST_IS_USER_PROVIDED_SERVICE ] =
318320 tracer . _tracer . _config . isServiceUserProvided ? 'true' : 'false'
319321
322+ this . _pendingRequestErrorTags = [ ]
320323 this . libraryConfigurationPromise = getLibraryConfiguration ( this . tracer , this . testConfiguration )
321324 . then ( ( libraryConfigurationResponse ) => {
322325 if ( libraryConfigurationResponse . err ) {
323326 log . error ( 'Cypress plugin library config response error' , libraryConfigurationResponse . err )
327+ this . _pendingRequestErrorTags . push ( {
328+ tag : DD_CI_LIBRARY_CONFIGURATION_ERROR ,
329+ value : 'true' ,
330+ } )
324331 } else {
325332 const {
326333 libraryConfig : {
@@ -415,6 +422,7 @@ class CypressPlugin {
415422 if ( this . testSessionSpan && this . testModuleSpan ) {
416423 testSuiteTags [ TEST_SESSION_ID ] = this . testSessionSpan . context ( ) . toTraceId ( )
417424 testSuiteTags [ TEST_MODULE_ID ] = this . testModuleSpan . context ( ) . toSpanId ( )
425+ Object . assign ( testSuiteTags , this . getSessionRequestErrorTags ( ) )
418426 // If testSuiteSpan couldn't be created, we'll use the testModuleSpan as the parent
419427 if ( ! this . testSuiteSpan ) {
420428 testSuiteTags [ TEST_SUITE_ID ] = this . testModuleSpan . context ( ) . toSpanId ( )
@@ -471,6 +479,14 @@ class CypressPlugin {
471479 } )
472480 }
473481
482+ /**
483+ * Returns request error tags from the test session span for propagation to test spans.
484+ * @returns {Record<string, string> }
485+ */
486+ getSessionRequestErrorTags ( ) {
487+ return getSessionRequestErrorTags ( this . testSessionSpan )
488+ }
489+
474490 ciVisEvent ( name , testLevel , tags = { } ) {
475491 incrementCountMetric ( name , {
476492 testLevel,
@@ -599,14 +615,20 @@ class CypressPlugin {
599615 } ,
600616 integrationName : TEST_FRAMEWORK_NAME ,
601617 } )
618+ for ( const { tag, value } of this . _pendingRequestErrorTags ) {
619+ this . testSessionSpan . setTag ( tag , value )
620+ }
621+ this . _pendingRequestErrorTags = [ ]
602622 this . ciVisEvent ( TELEMETRY_EVENT_CREATED , 'session' )
603623
624+ const sessionRequestErrorTags = getSessionRequestErrorTags ( this . testSessionSpan )
604625 this . testModuleSpan = this . tracer . startSpan ( `${ TEST_FRAMEWORK_NAME } .test_module` , {
605626 childOf : this . testSessionSpan ,
606627 tags : {
607628 [ COMPONENT ] : TEST_FRAMEWORK_NAME ,
608629 ...this . testEnvironmentMetadata ,
609630 ...testModuleSpanMetadata ,
631+ ...sessionRequestErrorTags ,
610632 } ,
611633 integrationName : TEST_FRAMEWORK_NAME ,
612634 } )
0 commit comments