@@ -12,8 +12,10 @@ import {
12
12
AI_RESPONSE_TEXT_ATTRIBUTE ,
13
13
AI_RESPONSE_TOOL_CALLS_ATTRIBUTE ,
14
14
AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE ,
15
+ AI_TOOL_CALL_ARGS_ATTRIBUTE ,
15
16
AI_TOOL_CALL_ID_ATTRIBUTE ,
16
17
AI_TOOL_CALL_NAME_ATTRIBUTE ,
18
+ AI_TOOL_CALL_RESULT_ATTRIBUTE ,
17
19
AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE ,
18
20
AI_USAGE_PROMPT_TOKENS_ATTRIBUTE ,
19
21
GEN_AI_RESPONSE_MODEL_ATTRIBUTE ,
@@ -111,8 +113,14 @@ function renameAttributeKey(attributes: Record<string, unknown>, oldKey: string,
111
113
function processToolCallSpan ( span : Span , attributes : SpanAttributes ) : void {
112
114
addOriginToSpan ( span , 'auto.vercelai.otel' ) ;
113
115
span . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_OP , 'gen_ai.execute_tool' ) ;
114
- span . setAttribute ( 'gen_ai.tool.call.id' , attributes [ AI_TOOL_CALL_ID_ATTRIBUTE ] ) ;
115
- span . setAttribute ( 'gen_ai.tool.name' , attributes [ AI_TOOL_CALL_NAME_ATTRIBUTE ] ) ;
116
+ renameAttributeKey ( attributes , AI_TOOL_CALL_NAME_ATTRIBUTE , 'gen_ai.tool.name' ) ;
117
+ renameAttributeKey ( attributes , AI_TOOL_CALL_ID_ATTRIBUTE , 'gen_ai.tool.call.id' ) ;
118
+ renameAttributeKey ( attributes , AI_TOOL_CALL_ARGS_ATTRIBUTE , 'gen_ai.tool.input' ) ;
119
+ renameAttributeKey ( attributes , AI_TOOL_CALL_RESULT_ATTRIBUTE , 'gen_ai.tool.output' ) ;
120
+ // https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-tool-type
121
+ if ( ! attributes [ 'gen_ai.tool.type' ] ) {
122
+ span . setAttribute ( 'gen_ai.tool.type' , 'function' ) ;
123
+ }
116
124
span . updateName ( `execute_tool ${ attributes [ AI_TOOL_CALL_NAME_ATTRIBUTE ] } ` ) ;
117
125
}
118
126
@@ -127,7 +135,7 @@ function processGenerateSpan(span: Span, name: string, attributes: SpanAttribute
127
135
const functionId = attributes [ AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE ] ;
128
136
if ( functionId && typeof functionId === 'string' && name . split ( '.' ) . length - 1 === 1 ) {
129
137
span . updateName ( `${ nameWthoutAi } ${ functionId } ` ) ;
130
- span . setAttribute ( 'ai.pipeline.name ' , functionId ) ;
138
+ span . setAttribute ( 'gen_ai.function_id ' , functionId ) ;
131
139
}
132
140
133
141
if ( attributes [ AI_PROMPT_ATTRIBUTE ] ) {
0 commit comments