Skip to main content
Auto-instruments LangChain/LangGraph by monkey-patching CallbackManager._configureSync (or .configure) to inject a FiddlerCallbackHandler into every invocation. Node.js only — requires @langchain/core as a peer dependency and uses node:async_hooks (via context) for context propagation. Uses a WeakSet to track patched modules so frozen ESM exports are handled correctly.

Methods

constructor(client: FiddlerClient)

client
FiddlerClient
required
An initialized FiddlerClient used by the callback handler to create spans.

async instrument(): Promise<void>

Auto-instrument by dynamically importing @langchain/core/callbacks/manager.

isInstrumented(): boolean

Check whether the instrumentor has successfully patched a CallbackManager module.
return
true if auto-instrumentation is active.

manuallyInstrument(module: CallbackManagerModule)

Manually instrument a specific @langchain/core/callbacks/manager module. This is the recommended approach for bundled environments.
module
CallbackManagerModule
required
The imported @langchain/core/callbacks/manager module.

uninstrument()

Remove the patch and restore the original CallbackManager behavior. Safe to call even if the instrumentor was never activated.