@@ -14,7 +14,7 @@ function makeSpanJSON(overrides: Partial<SpanJSON> = {}): SpanJSON {
1414 } ;
1515}
1616
17- function makeTransactionEvent ( spans : SpanJSON [ ] , hasGenAiSpans = false ) : Event {
17+ function makeTransactionEvent ( spans : SpanJSON [ ] ) : Event {
1818 return {
1919 type : 'transaction' ,
2020 transaction : 'GET /api/chat' ,
@@ -27,7 +27,7 @@ function makeTransactionEvent(spans: SpanJSON[], hasGenAiSpans = false): Event {
2727 } ,
2828 } ,
2929 sdkProcessingMetadata : {
30- ... ( hasGenAiSpans && { hasGenAiSpans : true } ) ,
30+ hasGenAiSpans : true ,
3131 } ,
3232 spans,
3333 } ;
@@ -92,14 +92,18 @@ describe('extractGenAiSpansFromEvent', () => {
9292 } ) ;
9393
9494 it ( 'returns undefined when hasGenAiSpans flag is not set' , ( ) => {
95- const event = makeTransactionEvent ( [ makeSpanJSON ( { op : 'gen_ai.chat' } ) ] , false ) ;
95+ const event : Event = {
96+ type : 'transaction' ,
97+ spans : [ makeSpanJSON ( { op : 'gen_ai.chat' } ) ] ,
98+ sdkProcessingMetadata : { } ,
99+ } ;
96100
97101 expect ( extractGenAiSpansFromEvent ( event , makeClient ( ) ) ) . toBeUndefined ( ) ;
98102 expect ( event . spans ) . toHaveLength ( 1 ) ;
99103 } ) ;
100104
101105 it ( 'returns undefined when there are no gen_ai spans' , ( ) => {
102- const event = makeTransactionEvent ( [ makeSpanJSON ( { op : 'http.client' } ) , makeSpanJSON ( { op : 'db.query' } ) ] , true ) ;
106+ const event = makeTransactionEvent ( [ makeSpanJSON ( { op : 'http.client' } ) , makeSpanJSON ( { op : 'db.query' } ) ] ) ;
103107
104108 expect ( extractGenAiSpansFromEvent ( event , makeClient ( ) ) ) . toBeUndefined ( ) ;
105109 expect ( event . spans ) . toHaveLength ( 2 ) ;
@@ -116,7 +120,7 @@ describe('extractGenAiSpansFromEvent', () => {
116120 } ) ;
117121
118122 it ( 'returns undefined when span streaming is enabled' , ( ) => {
119- const event = makeTransactionEvent ( [ makeSpanJSON ( { op : 'gen_ai.chat' } ) ] , true ) ;
123+ const event = makeTransactionEvent ( [ makeSpanJSON ( { op : 'gen_ai.chat' } ) ] ) ;
120124 const client = makeClient ( { traceLifecycle : 'stream' } ) ;
121125
122126 expect ( extractGenAiSpansFromEvent ( event , client ) ) . toBeUndefined ( ) ;
@@ -134,7 +138,7 @@ describe('extractGenAiSpansFromEvent', () => {
134138 op : 'http.client' ,
135139 } ) ;
136140
137- const event = makeTransactionEvent ( [ httpSpan , genAiSpan ] , true ) ;
141+ const event = makeTransactionEvent ( [ httpSpan , genAiSpan ] ) ;
138142 const result = extractGenAiSpansFromEvent ( event , makeClient ( ) ) ;
139143
140144 expect ( result ! [ 1 ] . items [ 0 ] ! . parent_span_id ) . toBe ( 'http001' ) ;
0 commit comments