@@ -46,24 +46,24 @@ def _apply_common_span_attributes(
4646
4747 Returns (genai_attributes) for use with metrics.
4848 """
49- request_model = invocation .request_model
50- provider = invocation .provider
5149 span .update_name (
52- f"{ GenAI .GenAiOperationNameValues .CHAT .value } { request_model } " .strip ()
50+ f"{ GenAI .GenAiOperationNameValues .CHAT .value } { invocation . request_model } " .strip ()
5351 )
5452 span .set_attribute (
5553 GenAI .GEN_AI_OPERATION_NAME , GenAI .GenAiOperationNameValues .CHAT .value
5654 )
57- if request_model :
58- span .set_attribute (GenAI .GEN_AI_REQUEST_MODEL , request_model )
59- if provider is not None :
55+ if invocation .request_model :
56+ span .set_attribute (
57+ GenAI .GEN_AI_REQUEST_MODEL , invocation .request_model
58+ )
59+ if invocation .provider is not None :
6060 # TODO: clean provider name to match GenAiProviderNameValues?
61- span .set_attribute (GenAI .GEN_AI_PROVIDER_NAME , provider )
61+ span .set_attribute (GenAI .GEN_AI_PROVIDER_NAME , invocation . provider )
6262
63- finish_reasons = [gen .finish_reason for gen in invocation .output_messages ]
64- if finish_reasons :
63+ if invocation .output_messages :
6564 span .set_attribute (
66- GenAI .GEN_AI_RESPONSE_FINISH_REASONS , finish_reasons
65+ GenAI .GEN_AI_RESPONSE_FINISH_REASONS ,
66+ [gen .finish_reason for gen in invocation .output_messages ],
6767 )
6868
6969 if invocation .response_model_name is not None :
0 commit comments