feat: log stream cancellation to sentry (#3759)

This commit is contained in:
cthomas
2025-08-05 16:07:30 -07:00
committed by GitHub
parent 77a99cf48b
commit 7d33254f5f
2 changed files with 32 additions and 10 deletions

View File

@@ -389,13 +389,24 @@ class AnthropicStreamingInterface:
self.anthropic_mode = None
except asyncio.CancelledError as e:
logger.info("Cancelled stream %s", e)
yield LettaStopReason(stop_reason=StopReasonType.cancelled)
raise
import traceback
logger.error("Cancelled stream %s: %s", e, traceback.format_exc())
ttft_span.add_event(
name="stop_reason",
attributes={"stop_reason": StopReasonType.cancelled.value, "error": str(e), "stacktrace": traceback.format_exc()},
)
raise e
except Exception as e:
logger.error("Error processing stream: %s", e)
import traceback
logger.error("Error processing stream: %s", e, traceback.format_exc())
ttft_span.add_event(
name="stop_reason",
attributes={"stop_reason": StopReasonType.error.value, "error": str(e), "stacktrace": traceback.format_exc()},
)
yield LettaStopReason(stop_reason=StopReasonType.error)
raise
raise e
finally:
logger.info("AnthropicStreamingInterface: Stream processing complete.")