Skip to content

Commit 5956ca8

Browse files
committed
set span name and some nitpicking
1 parent 0d853b4 commit 5956ca8

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

sentry_sdk/integrations/anthropic.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ def _sentry_patched_create_common(f, *args, **kwargs):
192192
except TypeError:
193193
return f(*args, **kwargs)
194194

195+
model = kwargs.get("model", "")
196+
195197
span = sentry_sdk.start_span(
196198
op=OP.GEN_AI_CHAT,
197-
description="Anthropic messages create",
199+
name=f"chat {model}",
198200
origin=AnthropicIntegration.origin,
199201
)
200202
span.__enter__()
@@ -207,11 +209,11 @@ def _sentry_patched_create_common(f, *args, **kwargs):
207209
if hasattr(result, "content"):
208210
input_tokens, output_tokens = _get_token_usage(result)
209211
_set_output_data(
210-
span,
211-
integration,
212-
getattr(result, "model", None),
213-
input_tokens,
214-
output_tokens,
212+
span=span,
213+
integration=integration,
214+
model=getattr(result, "model", None),
215+
input_tokens=input_tokens,
216+
output_tokens=output_tokens,
215217
content_blocks=[
216218
(
217219
content_block.to_dict()
@@ -243,8 +245,8 @@ def new_iterator():
243245
yield event
244246

245247
_set_output_data(
246-
span,
247-
integration,
248+
span=span,
249+
integration=integration,
248250
model=model,
249251
input_tokens=input_tokens,
250252
output_tokens=output_tokens,
@@ -268,8 +270,8 @@ async def new_iterator_async():
268270
yield event
269271

270272
_set_output_data(
271-
span,
272-
integration,
273+
span=span,
274+
integration=integration,
273275
model=model,
274276
input_tokens=input_tokens,
275277
output_tokens=output_tokens,

0 commit comments

Comments
 (0)