@arizeai/openinference-instrumentation-langchain
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

OpenInference Instrumentation for LangChain.js

This module provides automatic instrumentation for LangChain.js. which may be used in conjunction with @opentelemetry/sdk-trace-node.

Installation

npm install --save @arizeai/openinference-instrumentation-langchain

Usage

To load the Langchain instrumentation, manually instrument the @langchain/core/callbacks/manager module. The callbacks manager must be manually instrumented due to the non-traditional module structure in @langchain/core. Additional instrumentations can be registered as usual using the registerInstrumentations function.

import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { LangChainInstrumentation } from "@arizeai/openinference-instrumentation-langchain";
import * as CallbackManagerModule from "@langchain/core/callbacks/manager";

const provider = new NodeTracerProvider();
provider.register();

const lcInstrumentation = new LangChainInstrumentation();
// LangChain must be manually instrumented as it doesn't have a traditional module structure
lcInstrumentation.manuallyInstrument(CallbackManagerModule);

For more information on OpenTelemetry Node.js SDK, see the OpenTelemetry Node.js SDK documentation.

Deprecations

LangChain v0.1 was deprecated on 2025-03-02 due to security vulerabilities in the core package.

Readme

Keywords

none

Package Sidebar

Install

npm i @arizeai/openinference-instrumentation-langchain

Weekly Downloads

5,997

Version

3.2.0

License

Apache-2.0

Unpacked Size

594 kB

Total Files

122

Last publish

Collaborators

  • mikeldking
  • eunicode
  • koonal
  • parker-stafford
  • nickleach22
  • jackyxcs
  • cephalization