File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,7 @@ async def _call_llm(self, messages: list[ModelMessage]) -> ModelResponse:
234234
235235 # Try to use LLMObs for proper LLM Observability
236236 llmobs_span = None
237+ llmobs_span_exited = False
237238 try :
238239 from ddtrace .llmobs import LLMObs
239240
@@ -272,6 +273,7 @@ async def _call_llm(self, messages: list[ModelMessage]) -> ModelResponse:
272273 except Exception as e :
273274 if llmobs_span :
274275 self ._annotate_llmobs (llmobs_span , llmobs_input , error = e )
276+ llmobs_span_exited = True
275277 raise
276278
277279 logger .debug (
@@ -281,7 +283,7 @@ async def _call_llm(self, messages: list[ModelMessage]) -> ModelResponse:
281283 response .usage .response_tokens or 0 ,
282284 )
283285
284- if llmobs_span :
286+ if llmobs_span and not llmobs_span_exited :
285287 self ._annotate_llmobs (llmobs_span , llmobs_input , response = response )
286288
287289 self ._usage .add (
You can’t perform that action at this time.
0 commit comments