Skip to content
GitHubLog inStart free
cetra is not released yet. These docs describe the development version.

LangChain

cetra traces LangChain and LangGraph runs as a tree: the graph, its nodes, each model call and each tool call. For LangGraph graphs and Deep Agents, see LangGraph and Deep Agents.

Terminal window
pip install "cetra-sdk[langchain]" langchain langchain-openai
import cetra
from langchain_openai import ChatOpenAI
cetra.init(instrument=["langchain"])
model = ChatOpenAI(model="gpt-4o-mini")
model.invoke("What is the weather in Paris?")
cetra.flush()
  • A chat model call is an llm span with the provider, the messages, the tool definitions and the token counts.
  • A tool run is a tool span.
  • A LangGraph agent is a tree: the graph, each node as a chain span, the model calls and the tool calls under their nodes.
  • LangChain’s run metadata, such as langgraph_node and langgraph_step, is kept as span metadata.
  • Cost is computed from the token counts of each model call.

LangServe serves LangChain runnables over HTTP and has no spans of its own. Instrument the app’s LangChain code as this page shows, and add an OpenTelemetry FastAPI instrumentor for the HTTP layer if you want HTTP spans.

  • The fixtures were captured in Python with langchain 1.4.8, langchain-openai 1.7.3 and langgraph 1.2.19, with OpenInference 0.1.81 and OpenLLMetry 0.62.4.
  • With OpenLLMetry, the graph and its nodes come out as agent and chain spans with the provider langgraph.
  • The TypeScript helper is covered by an SDK test that builds the instrumentation from LangChain’s callback module. No spans of a LangChain.js run are captured.