-
Notifications
You must be signed in to change notification settings - Fork 567
Closed
Description
It seems that the integration modifies the Anthropic stream iterators to ignore events of type message_stop:
sentry-python/sentry_sdk/integrations/anthropic.py
Lines 177 to 211 in 3b28649
| def new_iterator(): | |
| # type: () -> Iterator[MessageStreamEvent] | |
| input_tokens = 0 | |
| output_tokens = 0 | |
| content_blocks = [] # type: list[str] | |
| for event in old_iterator: | |
| input_tokens, output_tokens, content_blocks = _collect_ai_data( | |
| event, input_tokens, output_tokens, content_blocks | |
| ) | |
| if event.type != "message_stop": | |
| yield event | |
| _add_ai_data_to_span( | |
| span, integration, input_tokens, output_tokens, content_blocks | |
| ) | |
| span.__exit__(None, None, None) | |
| async def new_iterator_async(): | |
| # type: () -> AsyncIterator[MessageStreamEvent] | |
| input_tokens = 0 | |
| output_tokens = 0 | |
| content_blocks = [] # type: list[str] | |
| async for event in old_iterator: | |
| input_tokens, output_tokens, content_blocks = _collect_ai_data( | |
| event, input_tokens, output_tokens, content_blocks | |
| ) | |
| if event.type != "message_stop": | |
| yield event | |
| _add_ai_data_to_span( | |
| span, integration, input_tokens, output_tokens, content_blocks | |
| ) | |
| span.__exit__(None, None, None) |
Is this intentional? This is a meaningful event (as indicated in the Anthropic documentation) and I wouldn't expect Sentry to modify this behavior.
Metadata
Metadata
Assignees
Labels
No labels
Projects
Status
No status