Skip to content

Commit 0e23407

Browse files
committed
revert langchain for now
1 parent db0772c commit 0e23407

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

sentry_sdk/integrations/langchain.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,6 @@ def on_chat_model_start(self, serialized, messages, *, run_id, **kwargs):
276276
elif "openai" in ai_type:
277277
span.set_data(SPANDATA.GEN_AI_SYSTEM, "openai")
278278

279-
agent_name = (
280-
sentry_sdk.get_current_scope()
281-
._contexts.get("langchain_agent", {})
282-
.get("agent_name")
283-
)
284-
if agent_name:
285-
span.set_data(SPANDATA.GEN_AI_AGENT_NAME, agent_name)
286-
287279
for key, attribute in DATA_FIELDS.items():
288280
if key in all_params and all_params[key] is not None:
289281
set_data_normalized(span, attribute, all_params[key], unpack=False)
@@ -436,14 +428,6 @@ def on_tool_start(self, serialized, input_str, *, run_id, **kwargs):
436428
if tool_description is not None:
437429
span.set_data(SPANDATA.GEN_AI_TOOL_DESCRIPTION, tool_description)
438430

439-
agent_name = (
440-
sentry_sdk.get_current_scope()
441-
._contexts.get("langchain_agent", {})
442-
.get("agent_name")
443-
)
444-
if agent_name:
445-
span.set_data(SPANDATA.GEN_AI_AGENT_NAME, agent_name)
446-
447431
if should_send_default_pii() and self.include_prompts:
448432
set_data_normalized(
449433
span,
@@ -772,9 +756,6 @@ def new_invoke(self, *args, **kwargs):
772756
name=f"invoke_agent {agent_name}" if agent_name else "invoke_agent",
773757
origin=LangchainIntegration.origin,
774758
) as span:
775-
sentry_sdk.get_current_scope().set_context(
776-
"langchain_agent", {"agent_name": agent_name, "tools": tools}
777-
)
778759
if agent_name:
779760
span.set_data(SPANDATA.GEN_AI_AGENT_NAME, agent_name)
780761

@@ -813,8 +794,6 @@ def new_invoke(self, *args, **kwargs):
813794
):
814795
set_data_normalized(span, SPANDATA.GEN_AI_RESPONSE_TEXT, output)
815796

816-
sentry_sdk.get_current_scope().remove_context("langchain_agent")
817-
818797
return result
819798

820799
return new_invoke
@@ -835,15 +814,11 @@ def new_stream(self, *args, **kwargs):
835814

836815
span = start_span_function(
837816
op=OP.GEN_AI_INVOKE_AGENT,
838-
name=f"invoke_agent {agent_name}" if agent_name else "invoke_agent",
817+
name=f"invoke_agent {agent_name}".strip(),
839818
origin=LangchainIntegration.origin,
840819
)
841820
span.__enter__()
842821

843-
sentry_sdk.get_current_scope().set_context(
844-
"langchain_agent", {"agent_name": agent_name, "tools": tools}
845-
)
846-
847822
if agent_name:
848823
span.set_data(SPANDATA.GEN_AI_AGENT_NAME, agent_name)
849824

@@ -893,8 +868,6 @@ def new_iterator():
893868
):
894869
set_data_normalized(span, SPANDATA.GEN_AI_RESPONSE_TEXT, output)
895870

896-
sentry_sdk.get_current_scope().remove_context("langchain_agent")
897-
898871
span.__exit__(None, None, None)
899872

900873
async def new_iterator_async():
@@ -914,8 +887,6 @@ async def new_iterator_async():
914887
):
915888
set_data_normalized(span, SPANDATA.GEN_AI_RESPONSE_TEXT, output)
916889

917-
sentry_sdk.get_current_scope().remove_context("langchain_agent")
918-
919890
span.__exit__(None, None, None)
920891

921892
if str(type(result)) == "<class 'async_generator'>":

0 commit comments

Comments
 (0)