LangChain.js
This module provides automatic instrumentation for LangChain.js, more specifically, the @langchain/core module. which may be used in conjunction with @opentelemetry/sdk-trace-node.
Install
npm install --save @arizeai/openinference-instrumentation-langchain \
@arizeai/phoenix-otelSetup
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.
import { register } from "@arizeai/phoenix-otel";
import { LangChainInstrumentation } from "@arizeai/openinference-instrumentation-langchain";
import * as CallbackManagerModule from "@langchain/core/callbacks/manager";
const provider = register({
projectName: "langchain-app",
});
const lcInstrumentation = new LangChainInstrumentation();
// LangChain must be manually instrumented as it doesn't have
// a traditional module structure
lcInstrumentation.manuallyInstrument(CallbackManagerModule);Support
Instrumentation version >1.0.0 supports both attribute masking and context attribute propagation to spans.
Instrumentation Version
LangChain ^0.3.0
LangChain ^0.2.0
LangChain ^0.1.0
>1.0.0
✅
✅
✅
>0.2.0
❌
✅
✅
>0.1.0
❌
❌
✅
Resources
Last updated
Was this helpful?