File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
tests/integrations/langchain Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -641,6 +641,13 @@ def on_tool_start(
641641 SPANDATA .GEN_AI_AGENT_NAME , agent_metadata ["lc_agent_name" ]
642642 )
643643
644+ run_name = kwargs .get ("name" )
645+ if run_name is not None :
646+ span .set_data (
647+ SPANDATA .GEN_AI_PIPELINE_NAME ,
648+ run_name ,
649+ )
650+
644651 if should_send_default_pii () and self .include_prompts :
645652 set_data_normalized (
646653 span ,
Original file line number Diff line number Diff line change @@ -220,6 +220,33 @@ def test_langchain_chat(
220220 assert chat_spans [0 ]["data" ]["gen_ai.pipeline.name" ] == "my-snazzy-pipeline"
221221
222222
223+ def test_langchain_tool (
224+ sentry_init ,
225+ capture_events ,
226+ ):
227+ sentry_init (
228+ integrations = [
229+ LangchainIntegration (
230+ include_prompts = True ,
231+ )
232+ ],
233+ traces_sample_rate = 1.0 ,
234+ send_default_pii = True ,
235+ )
236+ events = capture_events ()
237+
238+ with start_transaction ():
239+ get_word_length .invoke (
240+ {"word" : "eudca" },
241+ config = {"run_name" : "my-snazzy-pipeline" },
242+ )
243+
244+ tx = events [0 ]
245+ tool_spans = list (x for x in tx ["spans" ] if x ["op" ] == "gen_ai.execute_tool" )
246+ assert len (tool_spans ) == 1
247+ assert tool_spans [0 ]["data" ]["gen_ai.pipeline.name" ] == "my-snazzy-pipeline"
248+
249+
223250@pytest .mark .skipif (
224251 LANGCHAIN_VERSION < (1 ,),
225252 reason = "LangChain 1.0+ required (ONE AGENT refactor)" ,
You can’t perform that action at this time.
0 commit comments