@@ -49,7 +49,7 @@ def _apply_common_span_attributes(
4949 request_model = invocation .request_model
5050 provider = invocation .provider
5151 span .update_name (
52- f"{ GenAI .GenAiOperationNameValues .CHAT .value } { request_model } "
52+ f"{ GenAI .GenAiOperationNameValues .CHAT .value } { request_model } " . strip ()
5353 )
5454 span .set_attribute (
5555 GenAI .GEN_AI_OPERATION_NAME , GenAI .GenAiOperationNameValues .CHAT .value
@@ -72,11 +72,11 @@ def _apply_common_span_attributes(
7272 )
7373 if invocation .response_id is not None :
7474 span .set_attribute (GenAI .GEN_AI_RESPONSE_ID , invocation .response_id )
75- if isinstance ( invocation .input_tokens , ( int , float )) :
75+ if invocation .input_tokens is not None :
7676 span .set_attribute (
7777 GenAI .GEN_AI_USAGE_INPUT_TOKENS , invocation .input_tokens
7878 )
79- if isinstance ( invocation .output_tokens , ( int , float )) :
79+ if invocation .output_tokens is not None :
8080 span .set_attribute (
8181 GenAI .GEN_AI_USAGE_OUTPUT_TOKENS , invocation .output_tokens
8282 )
@@ -104,7 +104,7 @@ def _maybe_set_span_messages(
104104 )
105105
106106
107- def _maybe_set_span_extra_attributes (
107+ def _set_span_extra_attributes (
108108 span : Span ,
109109 attributes : Dict [str , Any ],
110110) -> None :
@@ -118,7 +118,7 @@ def _apply_finish_attributes(span: Span, invocation: LLMInvocation) -> None:
118118 _maybe_set_span_messages (
119119 span , invocation .input_messages , invocation .output_messages
120120 )
121- _maybe_set_span_extra_attributes (span , invocation .attributes )
121+ _set_span_extra_attributes (span , invocation .attributes )
122122
123123
124124def _apply_error_attributes (span : Span , error : Error ) -> None :
0 commit comments