Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bace8b1
Make agents integrations set the span status in case of error
antonpirker Sep 18, 2025
a16c781
Merge branch 'master' into antonpirker/agents-span-status
antonpirker Sep 19, 2025
0ae5b1e
Anthropic span and trx status
antonpirker Sep 19, 2025
a8d568f
correctly finish errored spans
antonpirker Sep 19, 2025
aba787a
HuggingFace span error status
antonpirker Sep 19, 2025
7b95818
fixed assertion
antonpirker Sep 19, 2025
cf568fb
Close errored spans in OpenAI
antonpirker Sep 19, 2025
a9298b7
fix assertion
antonpirker Sep 19, 2025
f6012fc
Merge branch 'antonpirker/agents-span-status' of github.com:getsentry…
antonpirker Sep 19, 2025
df15184
thats not the way
antonpirker Sep 19, 2025
bf2d0af
cleanup
antonpirker Sep 19, 2025
64eccb3
transaction errored in cohere
antonpirker Sep 19, 2025
61807ca
cleanup
antonpirker Sep 19, 2025
3106f4b
Refactor
antonpirker Sep 19, 2025
c0bda2b
cleanup
antonpirker Sep 19, 2025
e5c824a
cohere test
antonpirker Sep 19, 2025
ccd2593
langchain test
antonpirker Sep 19, 2025
7c06453
openai tests
antonpirker Sep 19, 2025
b42c6c0
openai agents test
antonpirker Sep 19, 2025
c65f6c5
complete error spans in anthropic
antonpirker Sep 19, 2025
d6a3824
Do not override an existing error status
antonpirker Sep 19, 2025
fbdf167
langchain work
antonpirker Sep 19, 2025
da0e847
Merge branch 'master' into antonpirker/agents-span-status
antonpirker Sep 22, 2025
8d52926
Merge branch 'master' into antonpirker/agents-span-status
antonpirker Sep 24, 2025
53d42dc
Merge branch 'master' into antonpirker/agents-span-status
antonpirker Sep 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
thats not the way
  • Loading branch information
antonpirker committed Sep 19, 2025
commit df15184b768385c62c285660ecd55ce0bd382874
14 changes: 2 additions & 12 deletions sentry_sdk/integrations/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,7 @@ def _sentry_patched_create_sync(*args, **kwargs):
integration = sentry_sdk.get_client().get_integration(AnthropicIntegration)
kwargs["integration"] = integration

try:
return _execute_sync(f, *args, **kwargs)
finally:
span = sentry_sdk.get_current_span()
if span is not None and span.status == SPANSTATUS.ERROR:
span.__exit__(None, None, None)
return _execute_sync(f, *args, **kwargs)

return _sentry_patched_create_sync

Expand Down Expand Up @@ -401,11 +396,6 @@ async def _sentry_patched_create_async(*args, **kwargs):
integration = sentry_sdk.get_client().get_integration(AnthropicIntegration)
kwargs["integration"] = integration

try:
return await _execute_async(f, *args, **kwargs)
finally:
span = sentry_sdk.get_current_span()
if span is not None and span.status == SPANSTATUS.ERROR:
span.__exit__(None, None, None)
return await _execute_async(f, *args, **kwargs)

return _sentry_patched_create_async
88 changes: 26 additions & 62 deletions sentry_sdk/integrations/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,18 +461,12 @@ def _execute_sync(f, *args, **kwargs):
@wraps(f)
def _sentry_patched_create_sync(*args, **kwargs):
# type: (Any, Any) -> Any
try:
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None or "messages" not in kwargs:
# no "messages" means invalid call (in all versions of openai), let it return error
return f(*args, **kwargs)

return _execute_sync(f, *args, **kwargs)
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None or "messages" not in kwargs:
# no "messages" means invalid call (in all versions of openai), let it return error
return f(*args, **kwargs)

finally:
span = sentry_sdk.get_current_span()
if span is not None and span.status == SPANSTATUS.ERROR:
span.__exit__(None, None, None)
return _execute_sync(f, *args, **kwargs)

return _sentry_patched_create_sync

Expand Down Expand Up @@ -502,18 +496,12 @@ async def _execute_async(f, *args, **kwargs):
@wraps(f)
async def _sentry_patched_create_async(*args, **kwargs):
# type: (Any, Any) -> Any
try:
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None or "messages" not in kwargs:
# no "messages" means invalid call (in all versions of openai), let it return error
return await f(*args, **kwargs)
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None or "messages" not in kwargs:
# no "messages" means invalid call (in all versions of openai), let it return error
return await f(*args, **kwargs)

return await _execute_async(f, *args, **kwargs)
finally:

span = sentry_sdk.get_current_span()
if span is not None and span.status == SPANSTATUS.ERROR:
span.__exit__(None, None, None)
return await _execute_async(f, *args, **kwargs)

return _sentry_patched_create_async

Expand Down Expand Up @@ -566,17 +554,11 @@ def _execute_sync(f, *args, **kwargs):
@wraps(f)
def _sentry_patched_create_sync(*args, **kwargs):
# type: (Any, Any) -> Any
try:
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None:
return f(*args, **kwargs)
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None:
return f(*args, **kwargs)

return _execute_sync(f, *args, **kwargs)

finally:
span = sentry_sdk.get_current_span()
if span is not None and span.status == SPANSTATUS.ERROR:
span.__exit__(None, None, None)
return _execute_sync(f, *args, **kwargs)

return _sentry_patched_create_sync

Expand Down Expand Up @@ -606,17 +588,11 @@ async def _execute_async(f, *args, **kwargs):
@wraps(f)
async def _sentry_patched_create_async(*args, **kwargs):
# type: (Any, Any) -> Any
try:
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None:
return await f(*args, **kwargs)

return await _execute_async(f, *args, **kwargs)
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None:
return await f(*args, **kwargs)

finally:
span = sentry_sdk.get_current_span()
if span is not None and span.status == SPANSTATUS.ERROR:
span.__exit__(None, None, None)
return await _execute_async(f, *args, **kwargs)

return _sentry_patched_create_async

Expand Down Expand Up @@ -671,17 +647,11 @@ def _execute_sync(f, *args, **kwargs):
@wraps(f)
def _sentry_patched_create_sync(*args, **kwargs):
# type: (Any, Any) -> Any
try:
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None:
return f(*args, **kwargs)
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None:
return f(*args, **kwargs)

return _execute_sync(f, *args, **kwargs)

finally:
span = sentry_sdk.get_current_span()
if span is not None and span.status == SPANSTATUS.ERROR:
span.__exit__(None, None, None)
return _execute_sync(f, *args, **kwargs)

return _sentry_patched_create_sync

Expand Down Expand Up @@ -711,16 +681,10 @@ async def _execute_async(f, *args, **kwargs):
@wraps(f)
async def _sentry_patched_responses_async(*args, **kwargs):
# type: (Any, Any) -> Any
try:
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None:
return await f(*args, **kwargs)
integration = sentry_sdk.get_client().get_integration(OpenAIIntegration)
if integration is None:
return await f(*args, **kwargs)

return await _execute_async(f, *args, **kwargs)

finally:
span = sentry_sdk.get_current_span()
if span is not None and span.status == SPANSTATUS.ERROR:
span.__exit__(None, None, None)
return await _execute_async(f, *args, **kwargs)

return _sentry_patched_responses_async
Loading