From 53fad652019f9aa474ff80889ecb3bd98c845863 Mon Sep 17 00:00:00 2001 From: Lukas Schmid Date: Tue, 3 Jun 2025 12:57:28 +0900 Subject: [PATCH 1/6] Update index.mdx paris is already the capital --- docs/platforms/python/integrations/langchain/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/python/integrations/langchain/index.mdx b/docs/platforms/python/integrations/langchain/index.mdx index 6cf7076cc3707..1a69b5d45fe71 100644 --- a/docs/platforms/python/integrations/langchain/index.mdx +++ b/docs/platforms/python/integrations/langchain/index.mdx @@ -82,7 +82,7 @@ sentry_sdk.init(...) # same as above llm = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=0, api_key="bad API key") with sentry_sdk.start_transaction(op="ai-inference", name="The result of the AI inference"): - response = llm.invoke([("system", "What is the capital of paris?")]) + response = llm.invoke([("system", "What is the capital of France?")]) print(response) ``` From 5b8bf3d743bf9a887797386cd5c91dc9fa6545d0 Mon Sep 17 00:00:00 2001 From: Lukas Schmid Date: Tue, 3 Jun 2025 13:06:33 +0900 Subject: [PATCH 2/6] Update index.mdx convert to chain --- docs/platforms/python/integrations/langchain/index.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/platforms/python/integrations/langchain/index.mdx b/docs/platforms/python/integrations/langchain/index.mdx index 1a69b5d45fe71..8fdd1005cb9b4 100644 --- a/docs/platforms/python/integrations/langchain/index.mdx +++ b/docs/platforms/python/integrations/langchain/index.mdx @@ -81,8 +81,9 @@ import sentry_sdk sentry_sdk.init(...) # same as above llm = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=0, api_key="bad API key") -with sentry_sdk.start_transaction(op="ai-inference", name="The result of the AI inference"): - response = llm.invoke([("system", "What is the capital of France?")]) + with sentry_sdk.start_transaction(op="ai-inference", name="The result of the AI inference"): + chain = (llm | StrOutputParser()).with_config({"run_name": "test-run"}) + response = chain.invoke([("system", "What is the capital of France?")]) print(response) ``` From 745e2232264f65fbbda80b01ce11274fe0957a0b Mon Sep 17 00:00:00 2001 From: Lukas Schmid Date: Tue, 3 Jun 2025 13:07:08 +0900 Subject: [PATCH 3/6] Update index.mdx indentation --- docs/platforms/python/integrations/langchain/index.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/platforms/python/integrations/langchain/index.mdx b/docs/platforms/python/integrations/langchain/index.mdx index 8fdd1005cb9b4..ba25910a85735 100644 --- a/docs/platforms/python/integrations/langchain/index.mdx +++ b/docs/platforms/python/integrations/langchain/index.mdx @@ -81,10 +81,10 @@ import sentry_sdk sentry_sdk.init(...) # same as above llm = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=0, api_key="bad API key") - with sentry_sdk.start_transaction(op="ai-inference", name="The result of the AI inference"): - chain = (llm | StrOutputParser()).with_config({"run_name": "test-run"}) - response = chain.invoke([("system", "What is the capital of France?")]) - print(response) + with sentry_sdk.start_transaction(op="ai-inference", name="The result of the AI inference"): + chain = (llm | StrOutputParser()).with_config({"run_name": "test-run"}) + response = chain.invoke([("system", "What is the capital of France?")]) + print(response) ``` After running this script, a transaction will be created in the Performance section of [sentry.io](https://sentry.io). Additionally, an error event (about the bad API key) will be sent to [sentry.io](https://sentry.io) and will be connected to the transaction. From 734bbc875eff9278bf45d3b7e9f946b3ab2b0260 Mon Sep 17 00:00:00 2001 From: Lukas Schmid Date: Tue, 3 Jun 2025 13:39:13 +0900 Subject: [PATCH 4/6] Update index.mdx Add hint to enable tracing to view data in LLM tab --- docs/platforms/python/integrations/langchain/index.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/platforms/python/integrations/langchain/index.mdx b/docs/platforms/python/integrations/langchain/index.mdx index ba25910a85735..8ec83f5a53dbb 100644 --- a/docs/platforms/python/integrations/langchain/index.mdx +++ b/docs/platforms/python/integrations/langchain/index.mdx @@ -36,6 +36,8 @@ An additional dependency, `tiktoken`, is required to be installed if you want to In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). +Tracing is required to see AI pipelines in sentry's [AI tab](https://sentry.io/insights/ai/llm-monitoring/). + Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. Date: Tue, 3 Jun 2025 13:49:12 +0900 Subject: [PATCH 5/6] Update index.mdx indentations --- docs/platforms/python/integrations/langchain/index.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/platforms/python/integrations/langchain/index.mdx b/docs/platforms/python/integrations/langchain/index.mdx index 8ec83f5a53dbb..9bcfe6cd85b4b 100644 --- a/docs/platforms/python/integrations/langchain/index.mdx +++ b/docs/platforms/python/integrations/langchain/index.mdx @@ -83,10 +83,10 @@ import sentry_sdk sentry_sdk.init(...) # same as above llm = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=0, api_key="bad API key") - with sentry_sdk.start_transaction(op="ai-inference", name="The result of the AI inference"): - chain = (llm | StrOutputParser()).with_config({"run_name": "test-run"}) - response = chain.invoke([("system", "What is the capital of France?")]) - print(response) +with sentry_sdk.start_transaction(op="ai-inference", name="The result of the AI inference"): + chain = (llm | StrOutputParser()).with_config({"run_name": "test-run"}) + response = chain.invoke([("system", "What is the capital of France?")]) + print(response) ``` After running this script, a transaction will be created in the Performance section of [sentry.io](https://sentry.io). Additionally, an error event (about the bad API key) will be sent to [sentry.io](https://sentry.io) and will be connected to the transaction. From 2ffcbc6cdaa252c64ac9982a1b3ed843dd04f1ac Mon Sep 17 00:00:00 2001 From: Luke31 Date: Tue, 3 Jun 2025 14:23:27 +0900 Subject: [PATCH 6/6] add import for StrOutputParser --- docs/platforms/python/integrations/langchain/index.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/platforms/python/integrations/langchain/index.mdx b/docs/platforms/python/integrations/langchain/index.mdx index 9bcfe6cd85b4b..32c753e96c095 100644 --- a/docs/platforms/python/integrations/langchain/index.mdx +++ b/docs/platforms/python/integrations/langchain/index.mdx @@ -78,6 +78,7 @@ Verify that the integration works by inducing an error: ```python from langchain_openai import ChatOpenAI +from langchain_core.output_parsers import StrOutputParser import sentry_sdk sentry_sdk.init(...) # same as above