Skip to main content
Python auto-instrumentation library for LangChain. These traces are fully OpenTelemetry compatible and can be sent to an OpenTelemetry collector for viewing, such as Arize Phoenix.

Compatibility

This instrumentation works with:
  • LangChain 1.x (langchain>=1.0.0): Modern agent framework built on LangGraph
  • LangChain Classic (langchain-classic>=1.0.0): Legacy chains and tools (formerly langchain 0.x)
  • All LangChain partner packages (langchain-openai, langchain-anthropic, langchain-google-vertexai, etc.)
The instrumentation hooks into langchain-core, which is the shared foundation used by all LangChain packages.

Installation

For LangChain Classic (Legacy Applications)

For Both (Migration Scenarios)

Quickstart

Example with LangChain 1.x (New Agent Framework)

Install packages needed for this demonstration:
Start the Phoenix app in the background as a collector. By default, it listens on http://localhost:6006:
The Phoenix app does not send data over the internet. It only operates locally on your machine.

Setup instrumentation

Configure OpenAI credentials

Create and run an agent

Example with LangChain Classic (Legacy Chains)

For legacy applications using LangChain Classic:
Visit the Phoenix app at http://localhost:6006 to see the traces.

More Info