@langchain/core/callbacks/manager module via the @arizeai/openinference-instrumentation-langchain package.
Prerequisites
- Node.js 18+
- An Arize AX account (sign up)
- An
OPENAI_API_KEYfrom the OpenAI Platform
Launch Arize AX
- Sign in to your Arize AX account.
- From Space Settings, copy your Space ID and API Key. You will set them as
ARIZE_SPACE_IDandARIZE_API_KEYbelow.
Install
Configure credentials
Setup tracing
Run LangChain.js
Expected output
Verify in Arize AX
- Open your Arize AX space and select project
langchain-js-tracing-example. - You should see a new trace within ~30 seconds containing a
RunnableSequenceparent span (CHAIN) wrappingChatPromptTemplate(CHAIN),ChatOpenAI(LLM, modelgpt-5.5), andStrOutputParser(CHAIN) child spans, with the prompt, response, and token usage attached to the LLM span. - If no traces appear, see Troubleshooting.
Check from the skill, CLI, or SDK
Confirm spans are actually reaching your Arize AX project. Use whichever fits your workflow — the skill and CLI work for any framework; the SDK check is shown for each language.- Arize skill (agent)
- AX CLI
- SDK
Install the Arize Skills plugin and let your coding agent check for you:Then prompt your agent:
Use the arize-trace skill to export and analyze recent traces from my project. Confirm spans are arriving, and summarize any errors or latency issues.
Span filter
The basic setup above exports every span the tracer provider receives. When LangChain runs alongside other instrumentations (@opentelemetry/instrumentation-http, Next.js’s built-in tracing, framework HTTP middleware), those instrumentations emit POST / GET spans for every fetch, and the LangChain spans nest under those HTTP roots. OpenInference-tagged spans carry an openinference.span.kind attribute that the LangChain instrumentor sets — checking for it is enough to drop non-OpenInference spans. Swap SimpleSpanProcessor in instrumentation.ts for a filtering subclass:
OpenInferenceFilteringSpanProcessor in instrumentation.ts:
npm install @arizeai/openinference-core lru-cache.
Troubleshooting
- No traces in Arize AX. Confirm
ARIZE_SPACE_IDandARIZE_API_KEYare set in the same shell that runsexample.ts. Enable OpenTelemetry debug logs withexport OTEL_LOG_LEVEL=debugand re-run. - LangChain spans missing but other spans present.
instrumentation.manuallyInstrument(CallbackManagerModule)must run before any code creates a LangChain client. Make sureimport { provider } from "./instrumentation"(or a side-effect-onlyimport "./instrumentation") is the first import in your entry point. 401from OpenAI. VerifyOPENAI_API_KEYis set and has access togpt-5.5. Swap for a model your key can call.- Process exits before spans flush. Spans are exported asynchronously; always
await provider.forceFlush()(orprovider.shutdown()) before the process exits to avoid losing trailing spans. - LangChain spans orphaned on the Traces tab. Expected when
isOpenInferenceSpanis the only filter — see Span filter above for theRootAwareOpenInferenceProcessorrecipe that promotes the first LangChain span to root.
Version compatibility
Instrumentation>=1.0.0 supports both attribute masking and context attribute propagation. The matrix below tracks instrumentor support across LangChain core releases:
| Instrumentation Version | LangChain ^0.3.0 | LangChain ^0.2.0 | LangChain ^0.1.0 |
|---|---|---|---|
>=1.0.0 | Yes | Yes | Yes |
>=0.2.0 | No | Yes | Yes |
>=0.1.0 | No | No | Yes |