arize-otel package is a lightweight convenience library to set up OpenTelemetry and send traces to Arize AX.
Tutorial on instrumenting a LangChain application (Python) and sending traces to Arize AX.
See here for more LangChain with Arize AX tutorials (Python).
Python Integration
API Key Setup
Before running your Python application, ensure you have the following environment variables set:Install
Install the necessary Python packages:langchain-* packages as needed, e.g., langchain-anthropic, langchain-google-genai)
Setup Tracing
Usearize.otel.register to configure the OpenTelemetry tracer and then apply the LangChainInstrumentor.
Run LangChain Example (Python)
By instrumenting LangChain, spans will be created whenever a chain, agent, or runnable is invoked and will be sent to Arize AX.Observe (Python)
Now that you have tracing set up, all invocations of LangChain components will be streamed to your Arize AX project for observability and evaluation.JavaScript/TypeScript Integration
The OpenInference LangChain instrumentation is also available for JavaScript/TypeScript.Check out the OpenInference JavaScript LangChain example.
Install (JS/TS)
Install the LangChain instrumentation package and OTLP gRPC exporter via npm:Setup Tracing (JS/TS)
Below is an exampleinstrumentation.ts file. You’ll need to install all imported packages.
instrumentation.ts: This file should be imported and run at the very beginning of your application’s lifecycle to ensure all LangChain operations are instrumented. For example, in a Node.js application, you might import it at the top of your main server file or use the node -r ./instrumentation.js your-app.js command.
Native Thread Tracking (JS/TS)
Arize AX supports native thread tracking with LangChain by enabling the use ofsession_id, thread_id, or conversation_id in the metadata of your LangChain calls. This allows for seamless tracking of multi-turn conversations.