@@ -22,6 +22,14 @@ export const validateSpans = {
2222 const allSpans = collector . spans . values ( ) ;
2323 const spansByTest = groupSpansBy ( allSpans , 'test' ) ;
2424 const invocations = [ ...collector . invocations . values ( ) ] ;
25+ const truncatedUpdatedName = `updated-${ 'x' . repeat ( 56 ) } ` ;
26+ const spanUpdatesFor = ( spanKey ) =>
27+ collector . spanUpdates
28+ . filter (
29+ ( update ) =>
30+ `${ update . invocationId } #${ update . spanContext . spanId } ` === spanKey
31+ )
32+ . map ( ( update ) => update . event . info ) ;
2533 const rootAttributes = invocations . flatMap (
2634 ( invocation ) => invocation . attributes
2735 ) ;
@@ -39,6 +47,8 @@ export const validateSpans = {
3947 expectedSpan : 'undefined-attr-op' ,
4048 } ,
4149 { test : 'setAttributes' , expectedSpan : 'set-attributes-op' } ,
50+ { test : 'setStatus' , expectedSpan : 'status-error-op' } ,
51+ { test : 'updateName' , expectedSpan : 'update-name-original' } ,
4252 { test : 'publicImportTracing' , expectedSpan : 'public-import-op' } ,
4353 {
4454 test : 'publicImportStartActiveSpan' ,
@@ -66,6 +76,66 @@ export const validateSpans = {
6676 assert ( span . closed , `${ test } : Span '${ expectedSpan } ' should be closed` ) ;
6777 }
6878
79+ {
80+ const statusSpans = spansByTest . get ( 'setStatus' ) || [ ] ;
81+ const errorSpan = statusSpans . find ( ( s ) => s . name === 'status-error-op' ) ;
82+ const okSpan = statusSpans . find ( ( s ) => s . name === 'status-ok-op' ) ;
83+
84+ const entries = [ ...collector . spans . entries ( ) ] ;
85+ const errorKey = entries . find ( ( [ , span ] ) => span === errorSpan ) [ 0 ] ;
86+ const okKey = entries . find ( ( [ , span ] ) => span === okSpan ) [ 0 ] ;
87+ assert . deepStrictEqual ( spanUpdatesFor ( errorKey ) , [
88+ {
89+ type : 'status' ,
90+ status : { code : 'error' , message : 'first error' } ,
91+ } ,
92+ {
93+ type : 'status' ,
94+ status : { code : 'error' , message : 'second error' } ,
95+ } ,
96+ { type : 'status' , status : { code : 'unset' } } ,
97+ ] ) ;
98+ assert . deepStrictEqual ( spanUpdatesFor ( okKey ) , [
99+ {
100+ type : 'status' ,
101+ status : { code : 'error' , message : 'temporary error' } ,
102+ } ,
103+ { type : 'status' , status : { code : 'ok' } } ,
104+ {
105+ type : 'status' ,
106+ status : { code : 'error' , message : 'error after ok' } ,
107+ } ,
108+ ] ) ;
109+ }
110+
111+ {
112+ const [ [ spanKey ] ] = [ ...collector . spans . entries ( ) ] . filter (
113+ ( [ , span ] ) => span . test === 'updateName'
114+ ) ;
115+ assert . deepStrictEqual ( spanUpdatesFor ( spanKey ) , [
116+ { type : 'name' , name : 'update-name-intermediate' } ,
117+ { type : 'name' , name : truncatedUpdatedName } ,
118+ ] ) ;
119+ }
120+
121+ {
122+ const invocation = invocations . find ( ( candidate ) =>
123+ candidate . attributes . some (
124+ ( { name, value } ) =>
125+ name === 'test' && value === 'updateInvocationSpan'
126+ )
127+ ) ;
128+ assert ( invocation , 'updateInvocationSpan: invocation present' ) ;
129+ const spanKey = `${ invocation . invocationId } #${ invocation . rootSpanId } ` ;
130+ assert . deepStrictEqual ( spanUpdatesFor ( spanKey ) , [
131+ { type : 'name' , name : 'updated-invocation' } ,
132+ {
133+ type : 'status' ,
134+ status : { code : 'error' , message : 'invocation error' } ,
135+ } ,
136+ ] ) ;
137+ }
138+
69139 // setAttributeUndefined should NOT have a 'skipped' attribute recorded.
70140 {
71141 const span = ( spansByTest . get ( 'setAttributeUndefined' ) || [ ] ) . find (
0 commit comments