@@ -49,7 +49,7 @@ def _apply_common_span_attributes(
49
49
request_model = invocation .request_model
50
50
provider = invocation .provider
51
51
span .update_name (
52
- f"{ GenAI .GenAiOperationNameValues .CHAT .value } { request_model } "
52
+ f"{ GenAI .GenAiOperationNameValues .CHAT .value } { request_model } " . strip ()
53
53
)
54
54
span .set_attribute (
55
55
GenAI .GEN_AI_OPERATION_NAME , GenAI .GenAiOperationNameValues .CHAT .value
@@ -72,11 +72,11 @@ def _apply_common_span_attributes(
72
72
)
73
73
if invocation .response_id is not None :
74
74
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 :
76
76
span .set_attribute (
77
77
GenAI .GEN_AI_USAGE_INPUT_TOKENS , invocation .input_tokens
78
78
)
79
- if isinstance ( invocation .output_tokens , ( int , float )) :
79
+ if invocation .output_tokens is not None :
80
80
span .set_attribute (
81
81
GenAI .GEN_AI_USAGE_OUTPUT_TOKENS , invocation .output_tokens
82
82
)
@@ -104,7 +104,7 @@ def _maybe_set_span_messages(
104
104
)
105
105
106
106
107
- def _maybe_set_span_extra_attributes (
107
+ def _set_span_extra_attributes (
108
108
span : Span ,
109
109
attributes : Dict [str , Any ],
110
110
) -> None :
@@ -118,7 +118,7 @@ def _apply_finish_attributes(span: Span, invocation: LLMInvocation) -> None:
118
118
_maybe_set_span_messages (
119
119
span , invocation .input_messages , invocation .output_messages
120
120
)
121
- _maybe_set_span_extra_attributes (span , invocation .attributes )
121
+ _set_span_extra_attributes (span , invocation .attributes )
122
122
123
123
124
124
def _apply_error_attributes (span : Span , error : Error ) -> None :
0 commit comments