@@ -143,7 +143,7 @@ private static void ProcessClaudeModelAttributes(Activity activity, Dictionary<s
143143 // input tokens not provided in Claude response body, so we estimate the value based on input length
144144 if ( jsonBody . TryGetValue ( "prompt" , out var input ) )
145145 {
146- activity . SetTag ( AWSSemanticConventions . AttributeGenAiInputTokens , Math . Ceiling ( ( double ) input . GetString ( ) . Length / 6 ) ) ;
146+ activity . SetTag ( AWSSemanticConventions . AttributeGenAiInputTokens , Convert . ToInt32 ( Math . Ceiling ( ( double ) input . GetString ( ) . Length / 6 ) ) ) ;
147147 }
148148 }
149149 else
@@ -156,7 +156,7 @@ private static void ProcessClaudeModelAttributes(Activity activity, Dictionary<s
156156 // output tokens not provided in Claude response body, so we estimate the value based on output length
157157 if ( jsonBody . TryGetValue ( "completion" , out var output ) )
158158 {
159- activity . SetTag ( AWSSemanticConventions . AttributeGenAiOutputTokens , Math . Ceiling ( ( double ) output . GetString ( ) . Length / 6 ) ) ;
159+ activity . SetTag ( AWSSemanticConventions . AttributeGenAiOutputTokens , Convert . ToInt32 ( Math . Ceiling ( ( double ) output . GetString ( ) . Length / 6 ) ) ) ;
160160 }
161161 }
162162 }
@@ -235,7 +235,7 @@ private static void ProcessCommandModelAttributes(Activity activity, Dictionary<
235235 // input tokens not provided in Command response body, so we estimate the value based on input length
236236 if ( jsonBody . TryGetValue ( "message" , out var input ) )
237237 {
238- activity . SetTag ( AWSSemanticConventions . AttributeGenAiInputTokens , Math . Ceiling ( ( double ) input . GetString ( ) . Length / 6 ) ) ;
238+ activity . SetTag ( AWSSemanticConventions . AttributeGenAiInputTokens , Convert . ToInt32 ( Math . Ceiling ( ( double ) input . GetString ( ) . Length / 6 ) ) ) ;
239239 }
240240 }
241241 else
@@ -248,7 +248,7 @@ private static void ProcessCommandModelAttributes(Activity activity, Dictionary<
248248 // completion tokens not provided in Command response body, so we estimate the value based on output length
249249 if ( jsonBody . TryGetValue ( "text" , out var output ) )
250250 {
251- activity . SetTag ( AWSSemanticConventions . AttributeGenAiOutputTokens , Math . Ceiling ( ( double ) output . GetString ( ) . Length / 6 ) ) ;
251+ activity . SetTag ( AWSSemanticConventions . AttributeGenAiOutputTokens , Convert . ToInt32 ( Math . Ceiling ( ( double ) output . GetString ( ) . Length / 6 ) ) ) ;
252252 }
253253 }
254254 }
@@ -331,7 +331,7 @@ private static void ProcessMistralModelAttributes(Activity activity, Dictionary<
331331 // input tokens not provided in Mistral response body, so we estimate the value based on input length
332332 if ( jsonBody . TryGetValue ( "prompt" , out var input ) )
333333 {
334- activity . SetTag ( AWSSemanticConventions . AttributeGenAiInputTokens , Math . Ceiling ( ( double ) input . GetString ( ) . Length / 6 ) ) ;
334+ activity . SetTag ( AWSSemanticConventions . AttributeGenAiInputTokens , Convert . ToInt32 ( Math . Ceiling ( ( double ) input . GetString ( ) . Length / 6 ) ) ) ;
335335 }
336336 }
337337 else
@@ -347,7 +347,7 @@ private static void ProcessMistralModelAttributes(Activity activity, Dictionary<
347347 // output tokens not provided in Mistral response body, so we estimate the value based on output length
348348 if ( output . TryGetProperty ( "text" , out var text ) )
349349 {
350- activity . SetTag ( AWSSemanticConventions . AttributeGenAiOutputTokens , Math . Ceiling ( ( double ) text . GetString ( ) . Length / 6 ) ) ;
350+ activity . SetTag ( AWSSemanticConventions . AttributeGenAiOutputTokens , Convert . ToInt32 ( Math . Ceiling ( ( double ) text . GetString ( ) . Length / 6 ) ) ) ;
351351 }
352352 }
353353 }
0 commit comments