24
24
from opentelemetry .trace import Span , SpanKind , Tracer
25
25
from opentelemetry .trace .status import Status , StatusCode
26
26
27
- from .span_attributes import LLMSpanAttributes
28
27
from .utils import (
29
28
extract_content ,
30
29
extract_tools_prompt ,
@@ -49,13 +48,10 @@ def traced_method(wrapped, instance, args, kwargs):
49
48
llm_prompts .append (tools_prompt if tools_prompt else item )
50
49
51
50
span_attributes = {** get_llm_request_attributes (kwargs )}
52
-
53
- attributes = LLMSpanAttributes (** span_attributes )
54
-
55
- span_name = f"{ attributes .gen_ai_operation_name } { attributes .gen_ai_request_model } "
51
+ span_name = f"{ span_attributes [GenAIAttributes .GEN_AI_OPERATION_NAME ]} { span_attributes [GenAIAttributes .GEN_AI_REQUEST_MODEL ]} "
56
52
57
53
span = tracer .start_span (name = span_name , kind = SpanKind .CLIENT )
58
- _set_input_attributes (span , attributes )
54
+ _set_input_attributes (span , span_attributes )
59
55
set_event_prompt (span , json .dumps (llm_prompts ))
60
56
61
57
try :
@@ -84,8 +80,8 @@ def traced_method(wrapped, instance, args, kwargs):
84
80
85
81
86
82
@silently_fail
87
- def _set_input_attributes (span , attributes : LLMSpanAttributes ):
88
- for field , value in attributes .model_dump ( by_alias = True ). items ():
83
+ def _set_input_attributes (span , attributes ):
84
+ for field , value in attributes .items ():
89
85
set_span_attribute (span , field , value )
90
86
91
87
@@ -219,7 +215,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
219
215
if exc_type is not None :
220
216
self .span .set_status (Status (StatusCode .ERROR , str (exc_val )))
221
217
self .span .set_attribute (
222
- ErrorAttributes .ERROR_TYPE , exc_type .__name__
218
+ ErrorAttributes .ERROR_TYPE , exc_type .__qualname__
223
219
)
224
220
finally :
225
221
self .cleanup ()
0 commit comments