Skip to content

Commit 7ec95fe

Browse files
docs
1 parent beb8f2c commit 7ec95fe

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sentry_sdk/integrations/anthropic.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,8 @@ def _wrap_message_stream_iter(
10081008
) -> "Callable[..., Iterator[MessageStreamEvent]]":
10091009
"""
10101010
Accumulates output data while iterating. When the returned iterator ends, set
1011-
output attributes on the AI Client Span and end the span.
1011+
output attributes on the AI Client Span and ends the span (unless the `close()`
1012+
or `__next__()` patches have already closed it).
10121013
"""
10131014

10141015
def __iter__(self: "MessageStream") -> "Iterator[MessageStreamEvent]":
@@ -1030,6 +1031,7 @@ def _wrap_message_stream_next(
10301031
) -> "Callable[..., MessageStreamEvent]":
10311032
"""
10321033
Accumulates output data from the returned event.
1034+
Closes the AI Client Span if `StopIteration` is raised.
10331035
"""
10341036

10351037
def __next__(self: "MessageStream") -> "MessageStreamEvent":
@@ -1064,7 +1066,8 @@ def _wrap_message_stream_close(
10641066
f: "Callable[..., None]",
10651067
) -> "Callable[..., None]":
10661068
"""
1067-
Closes the AI Client Span, unless the finally block in `_wrap_synchronous_message_iterator()` runs first.
1069+
Closes the AI Client Span, unless the finally block in `_wrap_synchronous_message_iterator()` or
1070+
the except block in the `__next__()` patch runs first.
10681071
"""
10691072

10701073
def close(self: "MessageStream") -> None:

0 commit comments

Comments
 (0)