OpenObserve Docs
IntegrationAIFrameworks

LangGraph → OpenObserve

Updated View MarkdownOpen in ChatGPTOpen in Claude

Automatically trace every graph execution, node transition, and LLM call in your LangGraph application. LangGraph builds on LangChain, so the same LangChain instrumentor captures the full graph execution.

Prerequisites

  • Python 3.9+
  • An OpenObserve account (cloud or self-hosted)
  • Your OpenObserve organisation ID and Base64-encoded auth token
  • An OpenAI API key (or whichever model backend your graph uses)

Installation

pip install openobserve-python-sdk opentelemetry-instrumentation-langchain langchain-openai langgraph python-dotenv

Configuration

Create a .env file in your project root:

OPENOBSERVE_URL=https://api.openobserve.ai/
OPENOBSERVE_ORG=your_org_id
OPENOBSERVE_AUTH_TOKEN=Basic <your_base64_token>
OPENAI_API_KEY=your-openai-api-key

Instrumentation

Call LangchainInstrumentor().instrument() before importing LangGraph or LangChain modules.

from dotenv import load_dotenv
load_dotenv()

from opentelemetry.instrumentation.langchain import LangchainInstrumentor
from openobserve import openobserve_init

LangchainInstrumentor().instrument()
openobserve_init()

from typing import TypedDict
from langchain_openai import ChatOpenAI
from langgraph.graph import StateGraph, END

llm = ChatOpenAI(model="gpt-4o-mini")


class State(TypedDict):
    question: str
    answer: str


def answer_node(state: State):
    response = llm.invoke([{"role": "user", "content": state["question"]}])
    return {"answer": response.content}


graph = StateGraph(State)
graph.add_node("answer", answer_node)
graph.set_entry_point("answer")
graph.add_edge("answer", END)
app = graph.compile()

result = app.invoke({"question": "What is OpenTelemetry?", "answer": ""})
print(result["answer"])

Multi-node graph

def summarise_node(state: State):
    response = llm.invoke([
        {"role": "user", "content": f"Summarise in five words: {state['answer']}"}
    ])
    return {"answer": response.content}

graph = StateGraph(State)
graph.add_node("answer", answer_node)
graph.add_node("summarise", summarise_node)
graph.set_entry_point("answer")
graph.add_edge("answer", "summarise")
graph.add_edge("summarise", END)
app = graph.compile()

result = app.invoke({"question": "What is distributed tracing?", "answer": ""})
print(result["answer"])

What Gets Captured

Each app.invoke() call produces a root span with child spans per node and LLM call. LangGraph adds graph-specific context via traceloop_association_properties_langgraph_* attributes.

AttributeDescription
operation_nameChatOpenAI.chat for LLM spans
traceloop_workflow_nameLangGraph
traceloop_entity_pathGraph node that made the call (e.g. answer)
traceloop_association_properties_langgraph_nodeNode name
traceloop_association_properties_langgraph_stepExecution step number
traceloop_association_properties_langgraph_triggersNode triggers for this step
traceloop_association_properties_ls_model_nameModel alias (e.g. gpt-4o-mini)
traceloop_association_properties_ls_provideropenai
gen_ai_request_modelModel name requested
gen_ai_response_modelResolved model version (e.g. gpt-4o-mini-2024-07-18)
gen_ai_systemopenai
gen_ai_usage_input_tokensInput token count
gen_ai_usage_output_tokensOutput token count
gen_ai_usage_cost_inputEstimated input cost in USD
gen_ai_usage_cost_outputEstimated output cost in USD
llm_request_typechat
durationSpan latency
span_statusUNSET on success, ERROR on failure

Viewing Traces

  1. Log in to OpenObserve and navigate to Traces in the left sidebar
  2. Filter by traceloop_workflow_name = LangGraph to find graph execution traces
  3. Click any root span to open the waterfall view and see per-node spans
  4. Check traceloop_association_properties_langgraph_node to identify which graph node each LLM call belongs to

LangGraph trace in OpenObserve, Waterfall view with the LangGraph.workflow span attributes

Next Steps

With LangGraph instrumented, every graph execution is recorded in OpenObserve with a full span hierarchy. From here you can visualise node execution order, measure per-node latency, and track token usage across complex multi-step pipelines.

Read More

Was this page helpful?

On this page