For the complete documentation index, see llms.txt. Markdown versions are available by appending .md to documentation URLs.

LangChain & LangGraph Observability with OpenTelemetry

SigNoz Cloud - This page applies to SigNoz Cloud editions.
Self-Host - This page applies to self-hosted SigNoz editions.

What is LangChain and LangGraph Observability?

LangChain 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 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.

With 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.

To get started, check out our example LangChain trip planner agent with OpenTelemetry-based observability/monitoring (via OpenInference). View the LangChain trip planner agent repository.

You can also check out our LangChain SigNoz MCP agent repository.

Prerequisites

  • A Python application using Python 3.8+
  • LangChain/LangGraph integrated into your app
  • Basic understanding of AI Agents and tool calling workflow
  • SigNoz setup (choose one):
  • pip installed for managing Python packages
  • Internet access to send telemetry data to SigNoz Cloud
  • (Optional but recommended) A Python virtual environment to isolate dependencies

Instrument LangChain and LangGraph with OpenTelemetry

To capture detailed telemetry from LangChain/LangGraph without modifying your core application logic, we use OpenInference, 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.

Check out the openinference-instrumentation-langchain package on PyPI for detailed setup instructions.

No-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.

Step 1: Install the necessary packages in your Python environment.

pip install \
  opentelemetry-distro \
  opentelemetry-exporter-otlp \
  opentelemetry-instrumentation-httpx \
  opentelemetry-instrumentation-system-metrics \
  langgraph \
  langchain \
  openinference-instrumentation-langchain

Step 2: Add Automatic Instrumentation

opentelemetry-bootstrap --action=install

Step 3: Configure logging level

To ensure logs are properly captured and exported, configure the root logger to emit logs at the INFO level or higher:

import logging
 
logging.getLogger().setLevel(logging.INFO)

This sets the minimum log level for the root logger to INFO, which ensures that logger.info() calls and higher severity logs (WARNING, ERROR, CRITICAL) are captured by the OpenTelemetry logging auto-instrumentation and sent to SigNoz.

Step 4: Run an example

from langchain.agents import create_agent
 
def add_numbers(a: int, b: int) -> int:
    """Add two numbers together and return the result."""
    return a + b
 
agent = create_agent(
    model="openai:gpt-5-mini",
    tools=[add_numbers],
    system_prompt="You are a helpful math tutor who can do calculations using the provided tools.",
)
 
# Run the agent
agent.invoke(
    {"messages": [{"role": "user", "content": "what is 42 + 58?"}]},
)

📌 Note: Ensure that the OPENAI_API_KEY environment variable is properly defined with your API key before running the code.

Step 5: Run your application with auto-instrumentation

OTEL_RESOURCE_ATTRIBUTES="service.name=<service_name>" \
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
OTEL_TRACES_EXPORTER=otlp \
OTEL_METRICS_EXPORTER=otlp \
OTEL_LOGS_EXPORTER=otlp \
OTEL_PYTHON_LOG_CORRELATION=true \
OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true \
opentelemetry-instrument <your_run_command>
  • <service_name> is the name of your service
  • <region>: Your SigNoz Cloud region
  • <your-ingestion-key>: Your SigNoz ingestion key
  • Replace <your_run_command> with the actual command you would use to run your application. For example: python main.py

Once configured, LangChain and LangGraph automatically emit traces, spans, and attributes for every agent request.

LangChain and LangGraph traces are available in SigNoz under the Traces tab:

Traces View
Traces of your LangChain Application

When 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:

Detailed Traces View
Detailed traces view of your LangChain Application

Send Traces with the LangSmith OpenTelemetry Exporter (Optional)

If your app already uses LangSmith, the LangSmith SDK can send LangChain and LangGraph traces to SigNoz over OTLP. You do not need a LangSmith API key. Do not combine this path with the OpenInference steps above. If LangChainInstrumentor().instrument() also runs, only the OpenInference spans reach SigNoz, so remove it first.

Step 1: Install the packages

pip install "langsmith[otel]>=0.4.25" langchain langchain-openai langgraph

Step 2: Create an example app

The example calls OpenAI, so set the OPENAI_API_KEY environment variable before you run it.

main.py
from typing import TypedDict
 
from langchain_openai import ChatOpenAI
from langgraph.graph import END, START, StateGraph
 
llm = ChatOpenAI(model="gpt-4.1-mini")
 
 
class State(TypedDict):
    question: str
    answer: str
 
 
def call_model(state: State) -> dict:
    return {"answer": llm.invoke(state["question"]).content}
 
 
graph = StateGraph(State)
graph.add_node("call_model", call_model)
graph.add_edge(START, "call_model")
graph.add_edge("call_model", END)
app = graph.compile()
 
print(app.invoke({"question": "Name one city in France."})["answer"])

Step 3: Run your application with the LangSmith OpenTelemetry exporter

LANGSMITH_TRACING=true \
LANGSMITH_OTEL_ENABLED=true \
LANGSMITH_OTEL_ONLY=true \
OTEL_SERVICE_NAME=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>" \
python main.py

Verify these values:

  • <service_name>: the name of your service
  • <region>: your SigNoz Cloud region
  • <your-ingestion-key>: your SigNoz ingestion key

LANGSMITH_OTEL_ONLY=true sends traces to SigNoz only. Without it, the SDK also sends traces to LangSmith, which needs a LangSmith API key. Enter the endpoint without a path, because the exporter adds /v1/traces. For Self-Hosted SigNoz, set OTEL_EXPORTER_OTLP_ENDPOINT to http://<signoz-host>:4318 and remove OTEL_EXPORTER_OTLP_HEADERS. The LangSmith SDK exports over OTLP/HTTP, so use port 4318, not 4317.

Each graph run creates a LangGraph span, a span for each node, and a ChatOpenAI span for the model call. In AI Observability, the model call shows its token counts, estimated cost, and messages. In Self-Hosted SigNoz, the cost shows only after you add a price for the model. With a custom collector configuration, also add the AI observability processors.

A LangGraph trace in SigNoz with the LangGraph, call_model, and ChatOpenAI spans, and the ChatOpenAI span details with tokens, cost, input, and output
A LangGraph trace from the LangSmith OpenTelemetry exporter
The Thread tab of a LangGraph trace in SigNoz, with the user message, the assistant reply, and the finish reason
The Thread tab shows the conversation of the trace

LangChain and LangGraph Observability in JavaScript

You can instrument your LangChain/LangGraph applications in JavaScript using the OpenInference LangChain Instrumentor package.

For detailed guidance on instrumenting JavaScript applications with OpenTelemetry and connecting them to SigNoz, see the SigNoz OpenTelemetry JavaScript instrumentation docs.

Trace the rest of your LLM application and retrieval stack:

Further reading:

Browse all LLM observability integrations to instrument the rest of your stack.

Is this page helpful

Last updated—November 05, 2026