For the complete documentation index, see llms.txt. This page is also available as Markdown.

Instrument LangChain

Recipe — instrument LangChain. Pointer to the SDK langchain_instrumented sample.

Canonical sample: samples/integrations/langchain_instrumented.py — auto-capture LangChain LCEL chain execution with LangChainCallbackHandler. Drop-in: no manual trace upload needed.

Quick wire-up

pip install 'layerlens[providers-openai]' # plus your LangChain extras
from layerlens import Stratix
from layerlens.instrument.adapters.frameworks.langchain import LangChainCallbackHandler

client = Stratix()
handler = LangChainCallbackHandler(client)
chain.invoke(input, config={"callbacks": [handler]})

The handler emits model.invoke, cost.record, and tool.call events to the configured HTTP sink.

See also

Last updated

Was this helpful?