LangGraph and LangChain
Both OpenLLMetry and OpenInference instrument LangChain, and LangGraph runs on LangChain’s callbacks, so either records each node, model call and tool call as a span with its inputs and outputs.
With OpenLLMetry
pip install traceloop-sdk langgraph langchain-openai
export TRACELOOP_BASE_URL=https://api.trazadb.com
export TRACELOOP_HEADERS="Authorization=Bearer%20$TRAZA_API_KEY"
from traceloop.sdk import Traceloop
Traceloop.init(app_name="research-graph")
def run(thread_id: str, question: str):
Traceloop.set_association_properties({"session_id": thread_id})
return graph.invoke({"messages": [("user", question)]},
config={"configurable": {"thread_id": thread_id}})
Using the graph’s thread_id as the session id makes a whole conversation,
across invocations, one run.
With OpenInference
pip install openinference-instrumentation-langchain opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
from openinference.instrumentation import using_session
from openinference.instrumentation.langchain import LangChainInstrumentor
# provider: a TracerProvider exporting to Traza Cloud, as in the Python guide
LangChainInstrumentor().instrument(tracer_provider=provider)
with using_session(session_id=thread_id):
graph.invoke(inputs, config={"configurable": {"thread_id": thread_id}})
The tracer provider setup is in the Python guide.
What you get
Each node is a span; model calls carry their model, token counts, prompt and completion; tools carry their arguments and results. That is enough for Guard to count steps and spot repeated calls, and for Replay to serve the graph’s model answers back to it.