@@ -22,7 +22,10 @@ import {
2222 ATTR_GEN_AI_TOOL_CALL_RESULT ,
2323 ATTR_GEN_AI_TOOL_NAME ,
2424} from "@opentelemetry/semantic-conventions/incubating" ;
25- import { transformLLMSpans , transformAiSdkSpanAttributes } from "../../src/lib/tracing/ai-sdk-transformations" ;
25+ import {
26+ transformLLMSpans ,
27+ transformAiSdkSpanAttributes ,
28+ } from "../../src/lib/tracing/ai-sdk-transformations" ;
2629
2730import { openai as vercel_openai } from "@ai-sdk/openai" ;
2831import { generateText , tool } from "ai" ;
@@ -50,7 +53,11 @@ describe("AI SDK v5 Compatibility Tests", () => {
5053 attributes : {
5154 "ai.model.provider" : "openai" ,
5255 } ,
53- spanContext : ( ) => ( { spanId : "test-span-id" , traceId : "test-trace-id" , traceFlags : 0 } ) ,
56+ spanContext : ( ) => ( {
57+ spanId : "test-span-id" ,
58+ traceId : "test-trace-id" ,
59+ traceFlags : 0 ,
60+ } ) ,
5461 parentSpanContext : undefined ,
5562 startTime : [ 0 , 0 ] ,
5663 endTime : [ 0 , 0 ] ,
@@ -69,16 +76,19 @@ describe("AI SDK v5 Compatibility Tests", () => {
6976 transformAiSdkSpanAttributes ( span ) ;
7077
7178 // Check that ai.sdk.version was added
72- assert . ok ( span . attributes [ "ai.sdk.version" ] , "ai.sdk.version should be set" ) ;
79+ assert . ok (
80+ span . attributes [ "ai.sdk.version" ] ,
81+ "ai.sdk.version should be set" ,
82+ ) ;
7383 assert . ok (
7484 typeof span . attributes [ "ai.sdk.version" ] === "string" ,
75- "ai.sdk.version should be a string"
85+ "ai.sdk.version should be a string" ,
7686 ) ;
7787 // Version should be like "4.3.19" or "5.0.121"
7888 assert . match (
7989 span . attributes [ "ai.sdk.version" ] as string ,
8090 / ^ \d + \. \d + \. \d + / ,
81- "Version should match semantic versioning format"
91+ "Version should match semantic versioning format" ,
8292 ) ;
8393 } ) ;
8494 } ) ;
@@ -182,7 +192,8 @@ describe("AI SDK v5 Compatibility Tests", () => {
182192
183193 transformLLMSpans ( attributes ) ;
184194
185- const transformedParams = attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .0.parameters` ] ;
195+ const transformedParams =
196+ attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .0.parameters` ] ;
186197 assert . ok ( transformedParams ) ;
187198 assert . ok ( transformedParams . includes ( "newProp" ) ) ;
188199 assert . ok ( ! transformedParams . includes ( "oldProp" ) ) ;
@@ -216,14 +227,16 @@ describe("AI SDK v5 Compatibility Tests", () => {
216227 attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .0.name` ] ,
217228 "v4Tool" ,
218229 ) ;
219- const v4Params = attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .0.parameters` ] ;
230+ const v4Params =
231+ attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .0.parameters` ] ;
220232 assert . ok ( v4Params . includes ( "v4Prop" ) ) ;
221233
222234 assert . strictEqual (
223235 attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .1.name` ] ,
224236 "v5Tool" ,
225237 ) ;
226- const v5Params = attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .1.parameters` ] ;
238+ const v5Params =
239+ attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .1.parameters` ] ;
227240 assert . ok ( v5Params . includes ( "v5Prop" ) ) ;
228241 } ) ;
229242 } ) ;
@@ -308,10 +321,7 @@ describe("AI SDK v5 Compatibility Tests", () => {
308321
309322 transformLLMSpans ( attributes ) ;
310323
311- assert . strictEqual (
312- attributes [ ATTR_GEN_AI_TOOL_NAME ] ,
313- "calculate" ,
314- ) ;
324+ assert . strictEqual ( attributes [ ATTR_GEN_AI_TOOL_NAME ] , "calculate" ) ;
315325 assert . strictEqual (
316326 attributes [ ATTR_GEN_AI_TOOL_CALL_ARGUMENTS ] ,
317327 '{"operation": "add", "a": 5, "b": 3}' ,
@@ -332,10 +342,7 @@ describe("AI SDK v5 Compatibility Tests", () => {
332342
333343 transformLLMSpans ( attributes ) ;
334344
335- assert . strictEqual (
336- attributes [ ATTR_GEN_AI_TOOL_NAME ] ,
337- "calculate" ,
338- ) ;
345+ assert . strictEqual ( attributes [ ATTR_GEN_AI_TOOL_NAME ] , "calculate" ) ;
339346 assert . strictEqual (
340347 attributes [ ATTR_GEN_AI_TOOL_CALL_ARGUMENTS ] ,
341348 '{"operation": "add", "a": 5, "b": 3}' ,
@@ -355,7 +362,11 @@ describe("AI SDK v5 Compatibility Tests", () => {
355362 "ai.toolCall.input" : '{"operation": "multiply", "a": 4, "b": 7}' ,
356363 "ai.toolCall.output" : '{"result": 28}' ,
357364 } ,
358- spanContext : ( ) => ( { spanId : "test-span-id" , traceId : "test-trace-id" , traceFlags : 0 } ) ,
365+ spanContext : ( ) => ( {
366+ spanId : "test-span-id" ,
367+ traceId : "test-trace-id" ,
368+ traceFlags : 0 ,
369+ } ) ,
359370 parentSpanContext : undefined ,
360371 startTime : [ 0 , 0 ] ,
361372 endTime : [ 0 , 0 ] ,
@@ -404,7 +415,11 @@ describe("AI SDK v5 Compatibility Tests", () => {
404415 "ai.toolCall.args" : '{"operation": "subtract", "a": 10, "b": 3}' ,
405416 "ai.toolCall.result" : '{"result": 7}' ,
406417 } ,
407- spanContext : ( ) => ( { spanId : "test-span-id" , traceId : "test-trace-id" , traceFlags : 0 } ) ,
418+ spanContext : ( ) => ( {
419+ spanId : "test-span-id" ,
420+ traceId : "test-trace-id" ,
421+ traceFlags : 0 ,
422+ } ) ,
408423 parentSpanContext : undefined ,
409424 startTime : [ 0 , 0 ] ,
410425 endTime : [ 0 , 0 ] ,
@@ -523,7 +538,10 @@ describe("AI SDK v5 Compatibility Tests", () => {
523538 assert . ok ( rootSpan , "Root AI span should exist" ) ;
524539
525540 // Verify tool schema was captured with 'parameters' attribute
526- const toolSchemaParam = rootSpan . attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .0.parameters` ] ;
541+ const toolSchemaParam =
542+ rootSpan . attributes [
543+ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .0.parameters`
544+ ] ;
527545 assert . ok ( toolSchemaParam , "Tool schema should be captured" ) ;
528546 assert . strictEqual (
529547 rootSpan . attributes [ `${ SpanAttributes . LLM_REQUEST_FUNCTIONS } .0.name` ] ,
@@ -533,7 +551,10 @@ describe("AI SDK v5 Compatibility Tests", () => {
533551 // Parse and verify the schema
534552 const schema = JSON . parse ( toolSchemaParam as string ) ;
535553 assert . ok ( schema . properties , "Schema should have properties" ) ;
536- assert . ok ( schema . properties . location , "Schema should have location property" ) ;
554+ assert . ok (
555+ schema . properties . location ,
556+ "Schema should have location property" ,
557+ ) ;
537558
538559 // Find tool call span
539560 const toolSpan = spans . find ( ( span ) => span . name === "getWeather.tool" ) ;
0 commit comments