Monitor LangChain with Sazabi
Last verified on Nov 8, 2026.
A LangChain application is a graph of calls: a chain invokes a model, the model asks for a tool, the tool returns, the chain runs again. A stack trace shows you the function that threw. It does not show the third model call in a loop that went wrong.
Sazabi, the AI-native observability and security platform, takes that call graph as OpenTelemetry traces. You add instrumentation to the app and point it at your intake URL. Sazabi ingests OpenTelemetry metrics (Prometheus metrics through an OpenTelemetry Collector) and OTLP traces through the same intake as your logs. It stores each metric data point and each span as a log record that its agent queries alongside your logs, so there is no separate metrics store to run.
What Sazabi reads from LangChain
One method: your app pushes OTLP spans to Sazabi. Nothing is pulled from LangChain, and Sazabi does not call back into your app.
The first thing to know comes from the Sazabi docs for this source. LangChain does not emit OpenTelemetry on its own. A package such as OpenInference hooks into LangChain and creates spans for chains, tools and LLM calls. Python and TypeScript are the supported runtimes.
The two runtimes differ. In Python, LangChainInstrumentor().instrument() runs once at startup, before LangChain is imported. In LangChain.js there is no module structure to patch, so you call manuallyInstrument with the callbacks manager yourself. Skip that call and the provider starts fine but no spans arrive.
This hooks into LangChain's callback system. LangChain's reference lists BaseCallbackHandler as extending the LLM, chain, tool and retriever mixins, which is why one handler can see all four kinds of work.
LangChain's own docs describe a different path. Agents built with create_agent trace to LangSmith through LANGSMITH_TRACING, and LangSmith accepts OpenTelemetry traces with LANGSMITH_OTEL_ENABLED. That path is independent of Sazabi. You can run both.
Model names and token counts depend on the provider. They come from the LLM client's response, so a provider that returns no usage data leaves those fields off the span.
Questions it answers
- How many model calls did one agent run make?
- Which tool did the agent call last before it gave up?
- Which model served the slowest runs this afternoon?
- Did output tokens jump after the last prompt change?
- Which spans arrive without token counts, and from which provider?
- What did the application log at the same moment a chain failed?
A worked example: an agent that never finishes
Say a support agent built with LangChain runs for minutes on a few requests. A LangChain agent is a model calling tools in a loop until the task is complete, so a stuck run looks like a loop that does not end. You instrumented with service.name set to my-langchain-app, the name used in the Sazabi docs.
Start with a count per run:
sazabi logs ask "for service my-langchain-app in the last hour, which traces have the most spans? show the top 5"A trace with hundreds of spans next to the usual dozen is your loop. Open it in a thread and ask the Sazabi agent which tool span repeats and what each repeat returned.
Show the span names in the largest my-langchain-app trace from the last hour,
in order, and say which tool is called again and again.Two readings are common. The same tool called with the same input each time means the model ignores the tool's answer, which points at the prompt or the tool's output format. A tool that returns an error each time means the failure is downstream, and the application logs from the same minute will say why. Because spans and logs sit in one place, you can ask for both in a single thread.
What to expect from the data
Spans describe the run, not your business data. If a field is absent, check the cheap causes first: the instrumentation ran after LangChain was imported, the TypeScript manual step is missing, or the provider sent no usage block.
How it fits with other integrations
LangChain is one of several frameworks listed under AI frameworks. Mastra sends agent traces through its own exporter, and OpenRouter can add a span per generation at the gateway. The wire format is covered on the OpenTelemetry integration page, and pricing explains how span volume counts.
Log sources
- LangChain (manual log source, ai frameworks): Add OpenInference instrumentation to your LangChain application and point it at a Sazabi endpoint to forward chain, tool, and LLM call traces.
Frequently Asked Questions
Does LangChain send OpenTelemetry data by itself?
No. The Sazabi docs say LangChain does not emit OpenTelemetry on its own. You add an instrumentation package such as OpenInference, which creates spans for chains, tools and LLM calls, and point those spans at your Sazabi intake URL.
Which LangChain runtimes work?
Python and TypeScript or JavaScript. Those are the only runtimes with a LangChain OpenInference package today. In LangChain.js you must wire in the callbacks manager by hand, or no spans appear.
Why are token counts missing from some spans?
Token counts and model names come from the LLM client response. If the provider returns no usage data, those fields are absent from the span.
Do I have to stop using LangSmith?
No. LangChain agents support LangSmith tracing through its own environment variables, and the Sazabi route is a separate OTLP export. They are independent connections.
Sources
- LangChain connects to Sazabi as a manual log source (accessed Nov 8, 2026)
- LangChain emits no OpenTelemetry on its own, OpenInference creates the spans, Python and TypeScript only, LangChain.js needs manual callbacks wiring, token counts depend on provider usage data (accessed Nov 8, 2026)
- Agents built with create_agent support tracing through LangSmith, and traces record tool calls and model interactions (accessed Nov 8, 2026)
- LangSmith accepts OpenTelemetry traces, LANGSMITH_OTEL_ENABLED switches on the LangChain integration, and OTLP/HTTP exporters append the /v1/traces signal path (accessed Nov 8, 2026)
- BaseCallbackHandler extends the LLM, chain, tool and retriever manager mixins (accessed Nov 8, 2026)