LangChain is a framework for building applications with LLMs. It provides agents, tools, chains, and integrations with model providers.
HoneyHive integrates with LangChain through the OpenInference instrumentor, automatically capturing agent runs, tool calls, chain executions, and LLM interactions.
Quick Start
Add HoneyHive tracing in just 4 lines of code. Add this to your existing LangChain app and all agents, tools, and model calls are automatically traced.
To see where to initialize the tracer for your environment, including AWS Lambda and long-running servers, see Tracer Initialization .
pip install "honeyhive[openinference-langchain]>=1.0.0rc0" langchain-openai
# Or install separately
pip install "honeyhive>=1.0.0rc0" openinference-instrumentation-langchain langchain langchain-openai
import os
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.langchain import LangChainInstrumentor
tracer = HoneyHiveTracer.init(
api_key = os.getenv( "HH_API_KEY" ),
project = os.getenv( "HH_PROJECT" ),
)
LangChainInstrumentor().instrument( tracer_provider = tracer.provider)
# Your existing LangChain code works unchanged
Tested Versions
HoneyHive’s LangChain integration is tested against the following versions on PyPI, as of April 2026. Newer patch releases are generally safe; if you hit an issue, pin to these versions to reproduce a known-good configuration.
Package Version langchain1.2.15 (minimum: >= 1.0.0, recommended: >= 1.2.0)openinference-instrumentation-langchain0.1.62
Requires Python 3.11+. The same instrumentor also traces LangGraph .
What Gets Traced
The instrumentor automatically captures:
Agent runs - Every create_agent invocation with inputs and outputs
LLM calls - Model requests, responses, and token usage
Tool calls - Each tool execution with arguments and results
Chain operations - LCEL pipes and chain invocations
No manual instrumentation required.
import os
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.langchain import LangChainInstrumentor
from langchain.agents import create_agent
from langchain_core.tools import tool
tracer = HoneyHiveTracer.init(
api_key = os.getenv( "HH_API_KEY" ),
project = os.getenv( "HH_PROJECT" ),
)
LangChainInstrumentor().instrument( tracer_provider = tracer.provider)
@tool
def calculator ( expression : str ) -> str :
"""Evaluate a basic arithmetic expression."""
return str ( eval (expression, { "__builtins__" : {}}, {}))
@tool
def policy_lookup ( topic : str ) -> str :
"""Look up company policy on a topic."""
policies = {
"soc2" : "SOC 2 focuses on security, availability, processing integrity, confidentiality, and privacy." ,
"retention" : "Default retention is 30 days unless compliance requires longer." ,
}
return policies.get(topic.lower(), "No policy found." )
agent = create_agent(
model = "openai:gpt-4o-mini" ,
tools = [calculator, policy_lookup],
system_prompt = "You are a support assistant. Use tools when needed." ,
)
result = agent.invoke(
{ "messages" : [{ "role" : "user" , "content" : "What is 17 * 3 + 5? Also summarize our SOC2 policy." }]}
)
print (result[ "messages" ][ - 1 ].content)
Example: Multi-Agent Routing
import os
from honeyhive import HoneyHiveTracer, trace
from openinference.instrumentation.langchain import LangChainInstrumentor
from langchain.agents import create_agent
from langchain_core.tools import tool
tracer = HoneyHiveTracer.init(
api_key = os.getenv( "HH_API_KEY" ),
project = os.getenv( "HH_PROJECT" ),
)
LangChainInstrumentor().instrument( tracer_provider = tracer.provider)
@tool
def calculator ( expression : str ) -> str :
"""Evaluate arithmetic."""
return str ( eval (expression, { "__builtins__" : {}}, {}))
@tool
def policy_lookup ( topic : str ) -> str :
"""Look up company policy."""
policies = { "soc2" : "SOC 2 covers security and privacy controls." , "retention" : "30-day default." }
return policies.get(topic.lower(), "No policy found." )
# Specialist agents
math_agent = create_agent( model = "openai:gpt-4o-mini" , tools = [calculator],
system_prompt = "You are a math specialist. Use calculator for all arithmetic." )
policy_agent = create_agent( model = "openai:gpt-4o-mini" , tools = [policy_lookup],
system_prompt = "You are a compliance specialist. Use policy_lookup for questions." )
coordinator = create_agent( model = "openai:gpt-4o-mini" , tools = [],
system_prompt = "Classify requests. Respond with one word: 'math' or 'policy'." )
@trace ( event_type = "chain" , event_name = "multi_agent_router" , tracer = tracer)
def route_to_specialist ( query : str ) -> str :
decision = coordinator.invoke({ "messages" : [{ "role" : "user" , "content" : query}]})
route = decision[ "messages" ][ - 1 ].content.strip().lower()
chosen = "math" if "math" in route else "policy"
tracer.enrich_span( metadata = { "router_choice" : chosen})
agent = math_agent if chosen == "math" else policy_agent
result = agent.invoke({ "messages" : [{ "role" : "user" , "content" : query}]})
return result[ "messages" ][ - 1 ].content
print (route_to_specialist( "Compute 24 * 7" ))
print (route_to_specialist( "What is our retention policy?" ))
In HoneyHive, you’ll see the full trace hierarchy: router decision, specialist agent delegation, tool executions, and LLM calls.
Troubleshooting
Traces not appearing
Pass the tracer provider - The instrumentor must receive tracer_provider=tracer.provider:
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.langchain import LangChainInstrumentor
tracer = HoneyHiveTracer.init( project = "your-project" )
# Correct - pass tracer_provider
LangChainInstrumentor().instrument( tracer_provider = tracer.provider)
# Wrong - missing tracer_provider
LangChainInstrumentor().instrument()
Check environment variables - Ensure HH_API_KEY and HH_PROJECT are set
Initialize before creating agents - Call instrument() before instantiating LangChain agents
Using with LangGraph
LangGraph uses the same OpenInference LangChain instrumentor. If you’ve already set up LangChain instrumentation, LangGraph state graphs are automatically traced too. See the LangGraph integration for custom StateGraph patterns.
LangGraph Integration Custom state graphs with conditional routing
Enrich Your Traces Add user IDs and custom metadata to LangChain traces
Custom Spans Create spans for business logic around agent calls
Distributed Tracing Trace agents across service boundaries
Using Traceloop (OpenLLMetry) Instead
If your project already uses Traceloop / OpenLLMetry , you can use its LangChain instrumentor instead of OpenInference. The setup is identical - only the install and import paths differ. Note the class name casing: Traceloop ships LangchainInstrumentor (lowercase “c”), while OpenInference ships LangChainInstrumentor.
pip install "honeyhive[traceloop-langchain]>=1.0.0rc0" langchain-openai
from honeyhive import HoneyHiveTracer
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
tracer = HoneyHiveTracer.init( project = "your-project" )
LangchainInstrumentor().instrument( tracer_provider = tracer.provider)
Tested version: opentelemetry-instrumentation-langchain 0.59.2 (April 2026). The same Traceloop package also traces LangGraph .
Resources