{"slug": "langchain-langgraph-observability-with-opentelemetry", "title": "LangChain & LangGraph Observability with OpenTelemetry", "summary": "SigNoz has released a new guide for instrumenting LangChain and LangGraph AI agent workflows with OpenTelemetry, enabling real-time observability of agent reasoning steps, tool invocations, and model responses. The integration allows developers to trace every user request from initial prompt through final answer, correlate traces with logs, and set alerts for latency or errors to improve AI application reliability.", "body_md": "What is LangChain and LangGraph Observability?\n\nLangChain and LangGraph observability gives you real-time visibility into your AI agent workflows by collecting traces, spans, and logs using OpenTelemetry. This guide shows you how to instrument your Python-based [LangChain](https://www.langchain.com/) or LangGraph application and send telemetry to SigNoz, so you can monitor agent reasoning steps, tool invocations, chain executions, and model responses end-to-end.\n\nWith full LangChain and LangGraph observability in SigNoz, you can trace every user request from the initial prompt through each reasoning step, tool execution, and final answer. Correlate traces with logs, set alerts for latency or errors, and continuously improve the reliability of your AI applications.\n\nTo get started, check out our example LangChain trip planner agent with OpenTelemetry-based observability/monitoring (via OpenInference). View the [LangChain trip planner agent repository](https://github.com/SigNoz/langchain-monitoring-demo).\n\nYou can also check out our [LangChain SigNoz MCP agent repository](https://github.com/SigNoz/signoz-mcp-demo).\n\nPrerequisites\n\n- A Python application using\n**Python 3.8+** - LangChain/LangGraph integrated into your app\n- Basic understanding of AI Agents and tool calling workflow\n- SigNoz setup (choose one):\n[SigNoz Cloud account](https://signoz.io/teams/)with an active ingestion key- Self-hosted SigNoz instance\n\n`pip`\n\ninstalled for managing Python packages- Internet access to send telemetry data to SigNoz Cloud\n*(Optional but recommended)*A Python virtual environment to isolate dependencies\n\nInstrument LangChain and LangGraph with OpenTelemetry\n\nTo capture detailed telemetry from LangChain/LangGraph without modifying your core application logic, we use [OpenInference](https://arize.com/docs/ax/observe/tracing/configure-tracing-options/instrument-with-openinference-helpers), a community-driven standard that provides pre-built instrumentation for popular AI frameworks like LangChain, built on top of OpenTelemetry. This allows you to trace your LangChain application with minimal configuration.\n\nCheck out the [openinference-instrumentation-langchain package on PyPI](https://pypi.org/project/openinference-instrumentation-langchain/) for detailed setup instructions.\n\nNo-code auto-instrumentation is recommended for quick setup with minimal code changes. It's ideal when you want to get observability up and running without modifying your application code and are leveraging standard instrumentor libraries.\n\n**Step 1:** Install the necessary packages in your Python environment.\n\n```\npip install \\\n  opentelemetry-distro \\\n  opentelemetry-exporter-otlp \\\n  opentelemetry-instrumentation-httpx \\\n  opentelemetry-instrumentation-system-metrics \\\n  langgraph \\\n  langchain \\\n  openinference-instrumentation-langchain\n```\n\n**Step 2:** Add Automatic Instrumentation\n\n```\nopentelemetry-bootstrap --action=install\n```\n\n**Step 3:** Configure logging level\n\nTo ensure logs are properly captured and exported, configure the root logger to emit logs at the INFO level or higher:\n\n``` python\nimport logging\n\nlogging.getLogger().setLevel(logging.INFO)\n```\n\nThis sets the minimum log level for the root logger to INFO, which ensures that `logger.info()`\n\ncalls and higher severity logs (WARNING, ERROR, CRITICAL) are captured by the OpenTelemetry logging auto-instrumentation and sent to SigNoz.\n\n**Step 4:** Run an example\n\n``` php\nfrom langchain.agents import create_agent\n\ndef add_numbers(a: int, b: int) -> int:\n    \"\"\"Add two numbers together and return the result.\"\"\"\n    return a + b\n\nagent = create_agent(\n    model=\"openai:gpt-5-mini\",\n    tools=[add_numbers],\n    system_prompt=\"You are a helpful math tutor who can do calculations using the provided tools.\",\n)\n\n# Run the agent\nagent.invoke(\n    {\"messages\": [{\"role\": \"user\", \"content\": \"what is 42 + 58?\"}]},\n)\n```\n\n📌 Note: Ensure that the\n\n`OPENAI_API_KEY`\n\nenvironment variable is properly defined with your API key before running the code.\n\n**Step 5:** Run your application with auto-instrumentation\n\n```\nOTEL_RESOURCE_ATTRIBUTES=\"service.name=<service_name>\" \\\nOTEL_EXPORTER_OTLP_ENDPOINT=\"https://ingest.<region>.signoz.cloud:443\" \\\nOTEL_EXPORTER_OTLP_HEADERS=\"signoz-ingestion-key=<your-ingestion-key>\" \\\nOTEL_EXPORTER_OTLP_PROTOCOL=grpc \\\nOTEL_TRACES_EXPORTER=otlp \\\nOTEL_METRICS_EXPORTER=otlp \\\nOTEL_LOGS_EXPORTER=otlp \\\nOTEL_PYTHON_LOG_CORRELATION=true \\\nOTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true \\\nopentelemetry-instrument <your_run_command>\n```\n\nis the name of your service`<service_name>`\n\n`<region>`\n\n: Your[SigNoz Cloud region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint)`<your-ingestion-key>`\n\n: Your SigNoz[ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/)- Replace\n`<your_run_command>`\n\nwith the actual command you would use to run your application. For example:`python main.py`\n\nUsing self-hosted SigNoz? Most steps are identical. To adapt this guide, update the endpoint and remove the ingestion key header as shown in [Cloud → Self-Hosted](https://signoz.io/docs/ingestion/cloud-vs-self-hosted/#cloud-to-self-hosted).\n\nCode-based instrumentation gives you fine-grained control over your telemetry configuration. Use this approach when you need to customize resource attributes, sampling strategies, or integrate with existing observability infrastructure.\n\n**Step 1:** Install OpenInference and OpenTelemetry related packages\n\n```\npip install openinference-instrumentation-langchain \\\nopentelemetry-exporter-otlp \\\nopentelemetry-sdk \\\nlanggraph \\\nlangchain\n```\n\n**Step 2:** Import the necessary modules in your Python application\n\n``` python\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import BatchSpanProcessor\nfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\nfrom opentelemetry.sdk.resources import Resource\nfrom openinference.instrumentation.langchain import LangChainInstrumentor\n```\n\n**Step 3:** Set up the OpenTelemetry Tracer Provider to send traces directly to SigNoz Cloud\n\n```\nresource = Resource.create({\"service.name\": \"<service_name>\"})\nprovider = TracerProvider(resource=resource)\nspan_exporter = OTLPSpanExporter(\n    endpoint=\"https://ingest.<region>.signoz.cloud:443/v1/traces\",\n    headers={\"signoz-ingestion-key\": \"<your-ingestion-key>\"},\n)\nprovider.add_span_processor(BatchSpanProcessor(span_exporter))\n```\n\nis the name of your service`<service_name>`\n\n- Set the\nto match your SigNoz Cloud`<region>`\n\n**region** - Replace\nwith your SigNoz`<your-ingestion-key>`\n\n**ingestion key**\n\nUsing self-hosted SigNoz? Most steps are identical. To adapt this guide, update the endpoint and remove the ingestion key header as shown in [Cloud → Self-Hosted](https://signoz.io/docs/ingestion/cloud-vs-self-hosted/#cloud-to-self-hosted).\n\n**Step 4:** Instrument LangChain using OpenInference\n\nUse the `LangChainInstrumentor`\n\nfrom OpenInference to automatically trace LangChain operations with your OpenTelemetry setup:\n\n```\nLangChainInstrumentor().instrument()\n```\n\n📌 Important: Place this code at the start of your application logic — before any LangChain/LangGraph functions are called or used — to ensure telemetry is correctly captured.\n\n**Step 5:** Run an example\n\n``` php\nfrom langchain.agents import create_agent\n\ndef add_numbers(a: int, b: int) -> int:\n    \"\"\"Add two numbers together and return the result.\"\"\"\n    return a + b\n\nagent = create_agent(\n    model=\"openai:gpt-5-mini\",\n    tools=[add_numbers],\n    system_prompt=\"You are a helpful math tutor who can do calculations using the provided tools.\",\n)\n\n# Run the agent\nagent.invoke(\n    {\"messages\": [{\"role\": \"user\", \"content\": \"what is 42 + 58?\"}]},\n)\n```\n\n📌 Note: Ensure that the\n\n`OPENAI_API_KEY`\n\nenvironment variable is properly defined with your API key before running the code.\n\nOnce configured, LangChain and LangGraph automatically emit traces, spans, and attributes for every agent request.\n\nLangChain and LangGraph traces are available in SigNoz under the Traces tab:\n\nWhen you click on a trace ID in SigNoz, you'll see a detailed view of the trace, including all associated spans, along with their events and attributes:\n\nUse the SigNoz MCP to automatically recognize important LangChain and LangGraph trace attributes and [create a custom dashboard using natural language](https://signoz.io/docs/ai/use-cases/dashboard-creation-natural-language/), with no manual configuration needed.\n\nLangChain and LangGraph Observability in JavaScript\n\nYou can instrument your LangChain/LangGraph applications in JavaScript using the [OpenInference LangChain Instrumentor](https://www.npmjs.com/package/@arizeai/openinference-instrumentation-langchain) package.\n\nFor detailed guidance on instrumenting JavaScript applications with OpenTelemetry and connecting them to SigNoz, see the [SigNoz OpenTelemetry JavaScript instrumentation docs](https://signoz.io/docs/instrumentation/opentelemetry-javascript/).", "url": "https://wpnews.pro/news/langchain-langgraph-observability-with-opentelemetry", "canonical_source": "https://signoz.io/docs/langchain-observability", "published_at": "2026-05-26 00:00:00+00:00", "updated_at": "2026-05-27 13:26:54.897074+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "ai-infrastructure", "large-language-models", "mlops"], "entities": ["LangChain", "LangGraph", "OpenTelemetry", "SigNoz", "OpenInference"], "alternates": {"html": "https://wpnews.pro/news/langchain-langgraph-observability-with-opentelemetry", "markdown": "https://wpnews.pro/news/langchain-langgraph-observability-with-opentelemetry.md", "text": "https://wpnews.pro/news/langchain-langgraph-observability-with-opentelemetry.txt", "jsonld": "https://wpnews.pro/news/langchain-langgraph-observability-with-opentelemetry.jsonld"}}