Skip to content

Comments

Fix LLMObs span double-exit issue with exit state tracking#2

Merged
0Shark merged 3 commits intofeature/datadog-setupfrom
copilot/sub-pr-1
Nov 29, 2025
Merged

Fix LLMObs span double-exit issue with exit state tracking#2
0Shark merged 3 commits intofeature/datadog-setupfrom
copilot/sub-pr-1

Conversation

Copy link

Copilot AI commented Nov 29, 2025

The LLMObs span cleanup logic could call __exit__ twice on the same span—once in the error handler and once in the success path—causing potential errors.

Changes

  • Add llmobs_span_exited flag to track span exit state
  • Set flag after exiting span in error handler
  • Check flag before exiting span in success path
llmobs_span = None
llmobs_span_exited = False
# ... span setup ...

try:
    response = await model_request(...)
except Exception as e:
    if llmobs_span:
        self._annotate_llmobs(llmobs_span, llmobs_input, error=e)
        llmobs_span_exited = True
    raise

if llmobs_span and not llmobs_span_exited:
    self._annotate_llmobs(llmobs_span, llmobs_input, response=response)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 29, 2025 00:07
Co-authored-by: 0Shark <47896217+0Shark@users.noreply.github.com>
Co-authored-by: 0Shark <47896217+0Shark@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on Datadog setup pull request Fix LLMObs span double-exit issue with exit state tracking Nov 29, 2025
Copilot AI requested a review from 0Shark November 29, 2025 00:10
@0Shark 0Shark marked this pull request as ready for review November 29, 2025 00:27
@0Shark 0Shark merged commit 0e3b017 into feature/datadog-setup Nov 29, 2025
3 of 5 checks passed
@0Shark 0Shark deleted the copilot/sub-pr-1 branch November 29, 2025 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants