Skip to content

Commit af88ebd

Browse files
limit span.__enter__ to legacy branches
1 parent f64445f commit af88ebd

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

sentry_sdk/integrations/anthropic.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ def _sentry_patched_create_sync(f: "Any", *args: "Any", **kwargs: "Any") -> "Any
654654
origin=AnthropicIntegration.origin,
655655
)
656656

657-
span.__enter__()
657+
span.__enter__()
658658

659659
_set_create_input_data(span, kwargs, integration)
660660

@@ -751,7 +751,7 @@ async def _sentry_patched_create_async(
751751
origin=AnthropicIntegration.origin,
752752
)
753753

754-
span.__enter__()
754+
span.__enter__()
755755

756756
_set_create_input_data(span, kwargs, integration)
757757

@@ -985,21 +985,19 @@ def _sentry_patched_enter(self: "MessageStreamManager") -> "MessageStream":
985985
attributes={
986986
"sentry.op": OP.GEN_AI_CHAT,
987987
"sentry.origin": AnthropicIntegration.origin,
988+
SPANDATA.GEN_AI_RESPONSE_STREAMING: True,
988989
},
989990
)
990-
991-
set_on_span = span.set_attribute
992991
else:
993992
span = get_start_span_function()(
994993
op=OP.GEN_AI_CHAT,
995994
name="chat" if self._model is None else f"chat {self._model}".strip(),
996995
origin=AnthropicIntegration.origin,
997996
)
998997

999-
set_on_span = span.set_data
1000-
span.__enter__()
998+
span.set_data(SPANDATA.GEN_AI_RESPONSE_STREAMING, True)
999+
span.__enter__()
10011000

1002-
set_on_span(SPANDATA.GEN_AI_RESPONSE_STREAMING, True)
10031001
_set_common_input_data(
10041002
span=span,
10051003
integration=integration,
@@ -1094,21 +1092,19 @@ async def _sentry_patched_aenter(
10941092
attributes={
10951093
"sentry.op": OP.GEN_AI_CHAT,
10961094
"sentry.origin": AnthropicIntegration.origin,
1095+
SPANDATA.GEN_AI_RESPONSE_STREAMING: True,
10971096
},
10981097
)
1099-
1100-
set_on_span = span.set_attribute
11011098
else:
11021099
span = get_start_span_function()(
11031100
op=OP.GEN_AI_CHAT,
11041101
name="chat" if self._model is None else f"chat {self._model}".strip(),
11051102
origin=AnthropicIntegration.origin,
11061103
)
11071104

1108-
set_on_span = span.set_data
1109-
span.__enter__()
1105+
span.set_data(SPANDATA.GEN_AI_RESPONSE_STREAMING, True)
1106+
span.__enter__()
11101107

1111-
set_on_span(SPANDATA.GEN_AI_RESPONSE_STREAMING, True)
11121108
_set_common_input_data(
11131109
span=span,
11141110
integration=integration,

0 commit comments

Comments
 (0)