From 94d848c02978f619993fca44d5f2f0e5a17264cb Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Tue, 14 Apr 2026 11:34:23 +0200 Subject: [PATCH 1/2] fix(langchain): Record run_name as gen_ai.function_id for text completions --- sentry_sdk/integrations/langchain.py | 2 +- tests/integrations/langchain/test_langchain.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/integrations/langchain.py b/sentry_sdk/integrations/langchain.py index 9a7e3c42e8..1be9cf006a 100644 --- a/sentry_sdk/integrations/langchain.py +++ b/sentry_sdk/integrations/langchain.py @@ -348,7 +348,7 @@ def on_llm_start( pipeline_name = kwargs.get("name") if pipeline_name: - span.set_data(SPANDATA.GEN_AI_PIPELINE_NAME, pipeline_name) + span.set_data(SPANDATA.GEN_AI_FUNCTION_ID, pipeline_name) if model: span.set_data( diff --git a/tests/integrations/langchain/test_langchain.py b/tests/integrations/langchain/test_langchain.py index f1cff8f58d..3a23dd6c77 100644 --- a/tests/integrations/langchain/test_langchain.py +++ b/tests/integrations/langchain/test_langchain.py @@ -155,7 +155,7 @@ def test_langchain_text_completion( llm_span = llm_spans[0] assert llm_span["description"] == "text_completion gpt-3.5-turbo" assert llm_span["data"]["gen_ai.system"] == "openai" - assert llm_span["data"]["gen_ai.pipeline.name"] == "my-snazzy-pipeline" + assert llm_span["data"]["gen_ai.function_id"] == "my-snazzy-pipeline" assert llm_span["data"]["gen_ai.request.model"] == "gpt-3.5-turbo" assert llm_span["data"]["gen_ai.response.text"] == "The capital of France is Paris." assert llm_span["data"]["gen_ai.usage.total_tokens"] == 25 @@ -1859,7 +1859,7 @@ def test_langchain_message_truncation(sentry_init, capture_events): llm_span = llm_spans[0] assert llm_span["data"]["gen_ai.operation.name"] == "text_completion" - assert llm_span["data"][SPANDATA.GEN_AI_PIPELINE_NAME] == "my_pipeline" + assert llm_span["data"][SPANDATA.GEN_AI_FUNCTION_ID] == "my_pipeline" assert SPANDATA.GEN_AI_REQUEST_MESSAGES in llm_span["data"] messages_data = llm_span["data"][SPANDATA.GEN_AI_REQUEST_MESSAGES] From fd7693b2651a68dc7ab1e2247bac5e4f7fe1d35b Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Tue, 14 Apr 2026 11:35:44 +0200 Subject: [PATCH 2/2] update variable name --- sentry_sdk/integrations/langchain.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/integrations/langchain.py b/sentry_sdk/integrations/langchain.py index 1be9cf006a..8acf215bfe 100644 --- a/sentry_sdk/integrations/langchain.py +++ b/sentry_sdk/integrations/langchain.py @@ -346,9 +346,9 @@ def on_llm_start( span.set_data(SPANDATA.GEN_AI_OPERATION_NAME, "text_completion") - pipeline_name = kwargs.get("name") - if pipeline_name: - span.set_data(SPANDATA.GEN_AI_FUNCTION_ID, pipeline_name) + run_name = kwargs.get("name") + if run_name: + span.set_data(SPANDATA.GEN_AI_FUNCTION_ID, run_name) if model: span.set_data(