Skip to content

Commit fbdf167

Browse files
committed
langchain work
1 parent d6a3824 commit fbdf167

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

sentry_sdk/integrations/langchain.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import sentry_sdk
66
from sentry_sdk.ai.monitoring import set_ai_pipeline_name
77
from sentry_sdk.ai.utils import set_data_normalized, get_start_span_function
8-
from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
8+
from sentry_sdk.consts import OP, SPANDATA
99
from sentry_sdk.integrations import DidNotEnable, Integration
1010
from sentry_sdk.scope import should_send_default_pii
11-
from sentry_sdk.tracing import Span
12-
from sentry_sdk.tracing_utils import _get_value
11+
from sentry_sdk.tracing_utils import _get_value, set_span_errored
1312
from sentry_sdk.utils import logger, capture_internal_exceptions
1413

1514
from typing import TYPE_CHECKING
@@ -26,6 +25,7 @@
2625
Union,
2726
)
2827
from uuid import UUID
28+
from sentry_sdk.tracing import Span
2929

3030

3131
try:
@@ -116,7 +116,7 @@ def _handle_error(self, run_id, error):
116116

117117
span_data = self.span_map[run_id]
118118
span = span_data.span
119-
span.set_status(SPANSTATUS.ERROR)
119+
set_span_errored(span)
120120

121121
sentry_sdk.capture_exception(error, span.scope)
122122

tests/integrations/langchain/test_langchain.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ def test_langchain_error(sentry_init, capture_events):
267267

268268

269269
def test_span_status_error(sentry_init, capture_events):
270+
global llm_type
271+
llm_type = "acme-llm"
272+
270273
sentry_init(
271274
integrations=[LangchainIntegration(include_prompts=True)],
272275
traces_sample_rate=1.0,

0 commit comments

Comments
 (0)