LangChain
Agents, chains, LCEL runnables, and tools auto-capture as a nested span tree.
Install the instrumentor and every chain, agent, and tool invocation inside wrap your agent becomes a span, with the underlying LLM calls nested below.
What's captured
| Construct | Span kind | Nested children |
|---|---|---|
AgentExecutor.invoke / arun | agent | llm per step, tool per tool call |
RunnableSequence / LCEL pipe | function | whatever the pipe contains |
@tool / StructuredTool | tool | — |
Retrievers (VectorStoreRetriever, BM25) | retrieval | — |
| Embeddings | llm | — |
Install
npm install langchain @langchain/core @opentelemetry/instrumentation-langchainpip install langchain langchain-openai opentelemetry-instrumentation-langchainMinimal example — ReAct agent with tools
import os, trodo
from langchain.agents import create_react_agent, AgentExecutor
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool
from langchain import hub
trodo.init(site_id=os.environ['TRODO_SITE_ID'])
@tool
def get_weather(city: str) -> str:
"""Return the current weather in a city."""
return f'Sunny in {city}, 72F'
llm = ChatOpenAI(model='gpt-4o-mini')
prompt = hub.pull('hwchase17/react')
agent = create_react_agent(llm, [get_weather], prompt)
executor = AgentExecutor(agent=agent, tools=[get_weather])
with trodo.wrap_agent('langchain-react') as run:
result = executor.invoke({'input': "What's the weather in SF?"})
run.set_output(result['output'])import trodo from 'trodo-node';
import { ChatOpenAI } from '@langchain/openai';
import { AgentExecutor, createReactAgent } from 'langchain/agents';
trodo.init({ siteId: process.env.TRODO_SITE_ID });
await trodo.wrapAgent('langchain-react', async (run) => {
const result = await executor.invoke({ input: "What's the weather in SF?" });
run.setOutput(result.output);
});The agent, each LLM step, and each tool call appear as a nested tree under the run.