3838from uuid import UUID
3939
4040from opentelemetry import trace
41- from opentelemetry .context import Context , get_current
4241from opentelemetry .instrumentation ._semconv import (
4342 _OpenTelemetrySemanticConventionStability ,
4443 _OpenTelemetryStabilitySignalType ,
7069@dataclass
7170class _SpanState :
7271 span : Span
73- context : Context
74- start_time : float
75- request_model : Optional [str ] = None
76- system : Optional [str ] = None
7772 children : List [UUID ] = field (default_factory = list )
7873
7974
@@ -82,11 +77,8 @@ def _get_genai_attributes(
8277 response_model : Optional [str ],
8378 operation_name : Optional [str ],
8479 system : Optional [str ],
85- framework : Optional [str ],
8680) -> Dict [str , AttributeValue ]:
8781 attributes : Dict [str , AttributeValue ] = {}
88- if framework is not None :
89- attributes ["gen_ai.framework" ] = framework
9082 if system :
9183 attributes [GenAI .GEN_AI_PROVIDER_NAME ] = system
9284 if operation_name :
@@ -103,15 +95,12 @@ def _set_initial_span_attributes(
10395 span : Span ,
10496 request_model : Optional [str ],
10597 system : Optional [str ],
106- framework : Optional [str ],
10798) -> None :
10899 span .set_attribute (
109100 GenAI .GEN_AI_OPERATION_NAME , GenAI .GenAiOperationNameValues .CHAT .value
110101 )
111102 if request_model :
112103 span .set_attribute (GenAI .GEN_AI_REQUEST_MODEL , request_model )
113- if framework is not None :
114- span .set_attribute ("gen_ai.framework" , framework )
115104 if system is not None :
116105 # TODO: clean system name to match GenAiProviderNameValues?
117106 span .set_attribute (GenAI .GEN_AI_PROVIDER_NAME , system )
@@ -258,13 +247,8 @@ def _span_for_invocation(self, invocation: LLMInvocation):
258247 parent_run_id = invocation .parent_run_id ,
259248 )
260249 with use_span (span , end_on_exit = False ) as span :
261- request_model = invocation .attributes .get ("request_model" )
262250 span_state = _SpanState (
263251 span = span ,
264- context = get_current (),
265- request_model = request_model ,
266- system = system ,
267- start_time = invocation .start_time ,
268252 )
269253 self .spans [invocation .run_id ] = span_state
270254 yield span
@@ -279,9 +263,8 @@ def _apply_common_span_attributes(
279263 """
280264 request_model = invocation .attributes .get ("request_model" )
281265 system = invocation .attributes .get ("system" )
282- framework = invocation .attributes .get ("framework" )
283266
284- _set_initial_span_attributes (span , request_model , system , framework )
267+ _set_initial_span_attributes (span , request_model , system )
285268
286269 finish_reasons = _collect_finish_reasons (invocation .chat_generations )
287270 if finish_reasons :
@@ -305,7 +288,6 @@ def _apply_common_span_attributes(
305288 response_model ,
306289 GenAI .GenAiOperationNameValues .CHAT .value ,
307290 system ,
308- framework ,
309291 )
310292 return (genai_attributes ,)
311293
0 commit comments