How to Add Tracing to LangChain Apps in 2026 (Without LangSmith Lock-in)
Add tracing to your LangChain app without LangSmith lock-in. Compare LangSmith, Glassbrain SDK wrapping, and OpenTelemetry with a step-by-step setup guide.
Adding Tracing to LangChain Apps Without LangSmith Lock-in
If you have ever tried to debug a LangChain agent that went sideways in production, you already know why langchain tracing is not optional. A single user request can fan out into five chained prompts, three tool invocations, a retriever call, and two retries, and if you are looking at flat console logs you have no real chance of understanding what happened. The default answer most teams reach for is LangSmith, the first-party observability product from the LangChain team. It works, it is tightly integrated, and it is the path of least resistance. But it is also a proprietary, closed platform that ties your observability to a single vendor, and its pricing has pushed many teams to look for langsmith alternatives that offer the same visibility without the lock-in.
This guide walks through the realistic options for langchain tracing in 2026. We will cover LangSmith itself, a framework-agnostic approach using Glassbrain that wraps the underlying OpenAI and Anthropic clients LangChain uses internally, and a DIY OpenTelemetry setup for teams that need full control. The goal is not to bash LangSmith. It is genuinely good software. The goal is to show you that langchain observability does not have to be coupled to the framework itself, and that you can get a clean visual trace tree, replay, and AI fix suggestions without rewriting a line of your chains or agents.
By the end, you will understand exactly how langchain debugging works when you use an SDK-wrapping approach, why it captures chains, agents, and tools correctly even though it does not know anything about LangChain, and how to migrate off LangSmith in about ten minutes if that is your goal. If you are building serious LLM applications and you want langchain without langsmith as your observability stack, this is the playbook.
Why LangChain Tracing Is Different
LangChain is not a single API call. It is an orchestration framework, and that changes everything about what good langchain tracing needs to show you. When you call a retrieval augmented generation chain, what actually happens under the hood is a sequence: the input is formatted, a retriever hits a vector store, the retrieved documents are stuffed into a prompt template, the template is sent to an LLM, the LLM response is parsed, and sometimes the parser triggers a retry with a corrected prompt. If any one of those steps misbehaves, you need to see that exact step, in context, with the full input and output.
Agents are even more aggressive. A ReAct agent or a tool-calling agent runs a loop: think, act, observe, repeat. Each iteration is a fresh LLM call with an ever-growing context window full of prior tool outputs. When an agent gets stuck in a loop, or calls the wrong tool, or hallucinates a tool argument, you need to see the entire loop as a tree, not as a flat log of twenty separate OpenAI calls with no relationship to each other.
This is why flat logging fails for langchain observability. Writing every prompt and completion to stdout gives you a wall of text with no parent-child relationships, no timing, no way to see which LLM call belonged to which chain invocation. You cannot tell whether the slow request was slow because of the retriever, the LLM, or the tool. You cannot see how the prompt evolved across iterations. You cannot diff a working run against a failing run.
Good langchain tracing needs three things: hierarchical structure so nested calls show as trees, full prompt and response capture so you can see exactly what the model saw, and replay so you can rerun a failing trace with a tweaked prompt and compare outputs. Anything less and you are back to print debugging a distributed system.
Three Options for LangChain Tracing
There are three realistic paths for langchain tracing in 2026, and each has clear trade-offs. Picking the right one depends on how committed you are to the LangChain ecosystem, how much you care about vendor lock-in, and how much engineering time you want to spend on observability plumbing versus shipping features.
LangSmith (First-Party)
LangSmith is built by the LangChain team and has the deepest integration possible. Turn on an environment variable and every chain, tool, retriever, and LLM call shows up in the LangSmith UI with full context. It understands LangChain-specific concepts like RunnableSequence, tool calls, and LangGraph nodes natively. The downside is that it is a closed, proprietary platform, your traces live in their infrastructure, and the pricing becomes painful as volume grows. You are also tightly coupled: if you ever want to move off LangChain, you are also moving off LangSmith.
Glassbrain (Framework-Agnostic SDK Wrapping)
Glassbrain takes a different approach. Instead of integrating with LangChain directly, it wraps the underlying OpenAI and Anthropic SDK clients that LangChain uses under the hood. Because every LangChain LLM call eventually routes through those SDKs, Glassbrain captures every chain, agent step, and tool invocation automatically without knowing anything about LangChain itself. This is the framework-agnostic path: it works with LangChain today, LlamaIndex tomorrow, and whatever comes next in 2027. One-line install, visual trace tree, replay without your API keys, AI fix suggestions, and 1,000 free traces per month with no credit card. No lock-in, no framework coupling, no migration cost if you change orchestration libraries.
OpenTelemetry (DIY)
OpenTelemetry is the open standard for distributed tracing, and there are community instrumentation packages for LangChain that emit OTel spans. The upside is total control and vendor portability. The downside is that you have to run the collector, pick a backend, and build or configure a UI that understands LLM-specific concepts like token counts, cost, and prompt diffing. For most teams, OpenTelemetry langchain tracing ends up being a six-week project that would have taken ten minutes with a hosted tool.
Honest comparison: LangSmith is easiest if you are all-in on the LangChain ecosystem and accept the lock-in. Glassbrain is the best middle ground for teams that want zero-effort langchain observability without coupling themselves to any framework or vendor. OpenTelemetry is right when you have a platform team and strict data residency requirements. For the vast majority of teams shipping production LangChain apps, the Glassbrain approach gives you 95 percent of the LangSmith experience with none of the lock-in.
Option 1: LangSmith
LangSmith is the easiest path if you have already decided that LangChain is a permanent part of your stack. The setup is genuinely two environment variables: a LangSmith API key and a tracing flag. Once those are set, every LangChain runnable, chain, agent, and tool is automatically traced with no code changes. The UI is built specifically for LangChain concepts, so you see RunnableSequences, tool calls, and LangGraph state transitions rendered natively. There is also a built-in prompt playground, evaluation harness, and dataset management.
The concerns are twofold. First is lock-in. LangSmith is a closed, proprietary product. Your traces live in their infrastructure, the UI is theirs, and the data format is internal. If you ever want to migrate off LangChain, or you want to trace a service that is not using LangChain, you are stuck with a partial solution. Even if you stay on LangChain, you have now bet your observability stack on a single vendor that also controls the framework itself. That is an unusual amount of coupling to accept.
Second is pricing. LangSmith has a free tier, but production workloads burn through it quickly. A single autonomous agent making fifteen LLM calls per user request can easily push a mid-sized product into paid tiers, and the paid tiers are not cheap. Teams that do napkin math on their projected trace volume often find themselves paying thousands per month for observability, which is hard to justify when the same visibility is available for a fraction of the cost elsewhere.
If you are comfortable with those trade-offs and you never plan to leave LangChain, LangSmith is a fine default. If either the lock-in or the pricing gives you pause, read on.
Option 2: Glassbrain (Recommended)
Glassbrain is the langchain tracing option we recommend for teams that want serious observability without the lock-in. The approach is genuinely clever: instead of integrating with LangChain as a framework, Glassbrain wraps the underlying OpenAI and Anthropic SDK clients that LangChain instantiates internally. Every time LangChain calls the OpenAI API to run a chain step, invoke an agent, or call a tool, that request goes through the wrapped client and gets captured with full prompt, response, tokens, cost, and latency.
This is the key insight that makes langchain without langsmith practical. LangChain is not a transport layer. It is an orchestration layer that eventually calls the same OpenAI or Anthropic SDKs you would call directly. If you wrap the SDK, you capture everything LangChain does, regardless of whether you are using chains, agents, LangGraph, LCEL, or whatever the framework evolves into next year. Framework changes do not break your tracing. Framework migrations do not require retooling your observability.
The developer experience is one line. Install glassbrain-js for TypeScript or glassbrain for Python, grab an API key, and wrap your OpenAI client with wrapOpenAI. That is it. Your LangChain chains, agents, and tool calls are now traced, and they show up in the Glassbrain dashboard as a visual trace tree with full parent-child nesting. You can click any node to see the exact prompt that was sent, the exact response that came back, the token counts, the cost, and the latency.
Beyond basic capture, Glassbrain adds three things LangSmith does not do as well. First, replay that works without you handing over your production API keys. You can rerun any failing trace with a modified prompt and compare outputs side by side. Second, AI fix suggestions that analyze failing traces and suggest specific prompt improvements or structural changes. Third, a generous free tier: 1,000 traces per month with no credit card required, which covers most hobby projects and early-stage products entirely.
No framework lock-in, no vendor lock-in, no migration cost if you ever change orchestration libraries. For langchain observability in 2026, this is the path of least long-term regret.
Option 3: OpenTelemetry
OpenTelemetry is the right answer for teams with strict data residency requirements, an existing observability platform they want to extend, or a dedicated platform engineering team with time to build custom tooling. There are community OpenTelemetry instrumentations for LangChain that emit standardized spans for every chain, agent, and tool invocation, and you can route those spans to any OTel-compatible backend: Jaeger, Tempo, Honeycomb, Datadog, or your own stack.
The upside is that you own your data and your tooling. You are not coupled to any LLM observability vendor, and your traces can live alongside your existing application telemetry in the same backend. This is a clean architecture for mature organizations.
The downsides are real. Generic OpenTelemetry backends are not built for LLM-specific concepts. Token counts, prompt diffing, response inspection, replay, and cost tracking are not first-class. You will either build them yourself or accept a degraded debugging experience compared to purpose-built tools. You also need to run a collector, manage sampling rules, and handle the storage costs of high-cardinality LLM trace data, which is expensive in most general-purpose backends.
For most teams, OpenTelemetry langchain tracing becomes a multi-month project that a hosted tool solves in an afternoon. Consider it if you have the engineering bandwidth and regulatory reasons to require it. Otherwise, the Glassbrain approach delivers the same outcome for dramatically less effort.
Step-by-Step: Glassbrain with LangChain
Here is the full setup for langchain tracing with Glassbrain, end to end. The total time from signup to first trace is under ten minutes.
Step one: sign up at Glassbrain and grab your project API key from the dashboard. No credit card is required for the 1,000 traces per month free tier.
Step two: install the SDK in your project. For TypeScript, run npm install glassbrain-js. For Python, run pip install glassbrain. Both packages are small and have minimal dependencies.
Step three: wrap the OpenAI or Anthropic client that LangChain uses underneath. In most LangChain apps, this means importing OpenAI from the openai package and passing the wrapped client into ChatOpenAI via the client parameter. For Python, use wrap_openai around your OpenAI client. For TypeScript, use wrapOpenAI. Set your Glassbrain API key via environment variable.
Step four: run your LangChain app as usual. You do not need to change a single line of your chain definitions, agent code, or tool implementations. Because Glassbrain sits at the SDK layer, every LangChain-initiated LLM call now routes through the wrapped client and gets captured automatically. Chains show up as parent nodes, individual LLM calls show up as children, tool invocations nest under the agent step that triggered them, and retries appear as siblings of the original call.
Step five: open the Glassbrain dashboard and watch your traces stream in. Click any trace to see the full visual trace tree. Expand any node to see prompts, responses, tokens, cost, and latency. If a trace failed, click the AI fix suggestions button to get a specific diagnosis and recommended prompt change. Use replay to rerun the trace with modifications and compare outputs.
That is the entire setup. No code restructuring, no callback handler registration, no LangChain-specific configuration. Just wrap the SDK and every chain, agent, and tool call becomes visible.
What You See After Setup
Once Glassbrain is capturing your langchain tracing data, the dashboard shows each user request as a visual trace tree. The root node is the top-level chain or agent invocation. Directly beneath it, you see every LLM call that chain made, in order, with timing. If you are using an agent, each iteration of the ReAct loop appears as a branch, with the LLM call as the parent and any tool calls as children. Retrievers, output parsers, and prompt template executions all nest correctly based on when they ran relative to the LLM calls they surround.
Click any LLM node to see the full prompt that was sent, including system messages, few-shot examples, and the accumulated conversation history. Click the response to see the raw completion, the parsed structured output, and any tool-calling arguments the model generated. Token counts and cost are shown per call and aggregated at the trace level. Latency is broken down by step so you can instantly see which part of your chain is slow.
For agent loops, you can watch the context window grow iteration by iteration, which makes loop debugging genuinely easy for the first time. You see the exact moment the agent loses the plot.
Frequently Asked Questions
Does Glassbrain work with LangChain? Yes. Glassbrain wraps the OpenAI and Anthropic SDK clients that LangChain uses internally, which means every LangChain chain, agent, tool invocation, and LLM call is captured automatically. You do not need any LangChain-specific integration because the tracing happens at the SDK layer that LangChain calls underneath.
Do I need to change my LangChain code? No. You wrap the OpenAI or Anthropic client once at the point where you instantiate it, and pass the wrapped client into your LangChain model wrappers like ChatOpenAI. Your chain definitions, agent logic, tool implementations, and prompt templates stay exactly as they are. Zero refactoring.
Can I use Glassbrain and LangSmith together? Yes. They operate at different layers and do not conflict. LangSmith captures at the LangChain framework level via callbacks. Glassbrain captures at the SDK level. You can run both simultaneously, which is useful during a migration period when you want to verify that Glassbrain is capturing everything LangSmith captured before you turn LangSmith off.
What about LangGraph? LangGraph is built on top of the same LangChain primitives and ultimately calls the same OpenAI and Anthropic SDKs. Glassbrain captures every LLM call inside your LangGraph nodes automatically. You see the graph execution as a sequence of LLM calls in the trace tree, with state transitions visible in the input and output of each node.
Does it trace agent loops correctly? Yes. Each iteration of a ReAct or tool-calling agent loop appears as a separate LLM call in the trace tree, in order, with the growing context window visible at each step. Tool invocations nest under the LLM call that triggered them. You can see exactly when an agent got stuck, looped, or called the wrong tool.
Can I migrate from LangSmith to Glassbrain? Yes, and the migration is usually under thirty minutes. Install glassbrain-js or glassbrain, wrap your OpenAI client, and run both tools in parallel for a few days to confirm parity. Once you trust the Glassbrain traces, remove the LangSmith environment variables. No code changes to your chains or agents are required.
Related Reading
- LangSmith alternatives compared
- Add LLM tracing without rewriting your app
- LLM tracing explained from first principles
Trace your LangChain app without LangSmith lock-in.
Try Glassbrain Free