Skip to main content
LangChain callback handler that creates Fiddler OTel spans for every chain, LLM, tool, agent, and retriever lifecycle event. Can be used directly by passing it in the callbacks array of a LangChain/LangGraph invocation, or automatically injected via LangGraphInstrumentor.

Properties

name: string

Methods

constructor(client: FiddlerClient)

client
FiddlerClient
required
An initialized FiddlerClient used to create spans.

handleAgentAction(action: AgentAction, runId: string)

Called when an agent is about to execute an action, with the action and the run ID.
action
AgentAction
required
The agent action containing tool name and input.
runId
string
required
Run identifier to look up the span.

handleAgentEnd(action: AgentFinish, runId: string)

Called when an agent finishes execution, before it exits. with the final output and the run ID.
action
AgentFinish
required
The agent finish containing return values.
runId
string
required
Run identifier to look up the span.

handleChainEnd(outputs: ChainValues, runId: string)

Called at the end of a Chain run, with the outputs and the run ID.
outputs
ChainValues
required
Output values produced by the chain.
runId
string
required
Run identifier to look up the span.

handleChainError(error: Error, runId: string)

Called if a Chain run encounters an error
error
Error
required
The error that occurred.
runId
string
required
Run identifier to look up the span.

handleChainStart(serialized: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>)

Called at the start of a Chain run, with the chain name and inputs and the run ID.
serialized
Serialized
required
Serialized chain/runnable metadata.
inputs
ChainValues
required
Input values passed to the chain.
runId
string
required
Unique run identifier.
parentRunId
string
Parent run ID for nesting.
tags
string[]
LangChain tags (used for LangGraph node detection).
metadata
Record<string, unknown>
LangChain metadata (agent name, node name, etc.).

handleChatModelStart(serialized: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, _tags?: string[], _metadata?: Record<string, unknown>, runName?: string)

Called at the start of a Chat Model run, with the prompt(s) and the run ID.
serialized
Serialized
required
Serialized chat model metadata.
messages
BaseMessage[][]
required
2D array of chat messages (outer = batches).
runId
string
required
Unique run identifier.
parentRunId
string
Parent run ID for nesting.
extraParams
Record<string, unknown>
Additional invocation parameters.
_tags
string[]
_metadata
Record<string, unknown>
runName
string
Optional explicit run name.

handleLLMEnd(output: LLMResult, runId: string)

Called at the end of an LLM/ChatModel run, with the output and the run ID.
output
LLMResult
required
The LLMResult containing generations and usage.
runId
string
required
Run identifier to look up the span.

handleLLMError(error: Error, runId: string)

Called if an LLM/ChatModel run encounters an error
error
Error
required
The error that occurred.
runId
string
required
Run identifier to look up the span.

handleLLMStart(serialized: Serialized, prompts: string[], runId: string, parentRunId?: string, _extraParams?: Record<string, unknown>, _tags?: string[], _metadata?: Record<string, unknown>, runName?: string)

Called at the start of an LLM or Chat Model run, with the prompt(s) and the run ID.
serialized
Serialized
required
Serialized LLM metadata.
prompts
string[]
required
Array of prompt strings.
runId
string
required
Unique run identifier.
parentRunId
string
Parent run ID for nesting.
_extraParams
Record<string, unknown>
_tags
string[]
_metadata
Record<string, unknown>
runName
string
Optional explicit run name.

handleRetrieverEnd(documents: { metadata?: unknown; pageContent?: string }[], runId: string)

Called when a retriever returns documents. Sets the concatenated page content as the tool output.
documents
{ metadata?: unknown; pageContent?: string }[]
required
Array of retrieved documents with pageContent.
runId
string
required
Run identifier to look up the span.

handleRetrieverError(error: Error, runId: string)

Called when a retriever throws an error.
error
Error
required
The error that occurred.
runId
string
required
Run identifier to look up the span.

handleRetrieverStart(serialized: Serialized, query: string, runId: string, parentRunId?: string)

Called when a retriever begins fetching documents. Creates a tool-type span with the retriever name and query.
serialized
Serialized
required
Serialized retriever metadata.
query
string
required
The search query string.
runId
string
required
Unique run identifier.
parentRunId
string
Parent run ID for nesting.

handleToolEnd(output: string, runId: string)

Called at the end of a Tool run, with the tool output and the run ID.
output
string
required
Tool output (string or ToolMessage-like object).
runId
string
required
Run identifier to look up the span.

handleToolError(error: Error, runId: string)

Called if a Tool run encounters an error
error
Error
required
The error that occurred.
runId
string
required
Run identifier to look up the span.

handleToolStart(serialized: Serialized, input: string, runId: string, parentRunId?: string, _tags?: string[], _metadata?: Record<string, unknown>, runName?: string)

Called at the start of a Tool run, with the tool name and input and the run ID.
serialized
Serialized
required
Serialized tool metadata.
input
string
required
The input string or structured input for the tool.
runId
string
required
Unique run identifier.
parentRunId
string
Parent run ID for nesting.
_tags
string[]
_metadata
Record<string, unknown>
runName
string
Optional explicit run name.