
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
@arizeai/openinference-instrumentation-langchain
Advanced tools
OpenInference Instrumentation for LangChain.js
This module provides automatic instrumentation for LangChain.js. which may be used in conjunction with @opentelemetry/sdk-trace-node.
npm install --save @arizeai/openinference-instrumentation-langchain
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.
You can specify a custom tracer provider when creating the LangChain instrumentation. This is useful when you want to use a non-global tracer provider or have more control over the tracing configuration.
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { Resource } from "@opentelemetry/resources";
import { SEMRESATTRS_PROJECT_NAME } from "@arizeai/openinference-semantic-conventions";
import { LangChainInstrumentation } from "@arizeai/openinference-instrumentation-langchain";
import * as CallbackManagerModule from "@langchain/core/callbacks/manager";
// Create a custom tracer provider
const customTracerProvider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_PROJECT_NAME]: "my-langchain-project",
}),
});
// Pass the custom tracer provider to the instrumentation
const lcInstrumentation = new LangChainInstrumentation({
tracerProvider: customTracerProvider,
});
// Manually instrument the LangChain module
lcInstrumentation.manuallyInstrument(CallbackManagerModule);
Alternatively, you can set the tracer provider after creating the instrumentation:
const lcInstrumentation = new LangChainInstrumentation();
lcInstrumentation.setTracerProvider(customTracerProvider);
LangChain v0.1 was deprecated on 2025-03-02 due to security vulerabilities in the core package.
FAQs
OpenInference Instrumentation for LangChain.js
The npm package @arizeai/openinference-instrumentation-langchain receives a total of 10,167 weekly downloads. As such, @arizeai/openinference-instrumentation-langchain popularity was classified as popular.
We found that @arizeai/openinference-instrumentation-langchain demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.