Fiddler LangGraph SDK
Auto-instrument LangGraph agents with Fiddler's native SDK
✓ GA | 🏆 Native SDK
Auto-instrument your LangGraph agent applications with OpenTelemetry-based tracing for comprehensive agentic observability. The Fiddler LangGraph SDK provides zero-configuration monitoring of complex multi-agent workflows, capturing every step from thought to action to execution.
What You'll Need
Fiddler account (cloud or on-premises)
Python 3.10 or higher
LangChain LangGraph application
Fiddler API key
Quick Start
Get monitoring in 3 steps:
# Step 1: Install
pip install fiddler-langgraph
# Step 2: Set environment variables
export FIDDLER_API_KEY="your-api-key"
export FIDDLER_URL="https://app.fiddler.ai" # or your on-prem URL
# Step 3: Your LangGraph app is now auto-instrumented!
# No code changes needed - just run your application
from langgraph.graph import StateGraph
# ... your existing LangGraph code ...That's it! Your agent traces are now flowing to Fiddler.
What Gets Monitored
The LangGraph SDK automatically captures:
Hierarchical Tracing
Application Level - Overall system performance and health
Session Level - User interaction and conversation flows
Agent Level - Individual agent behavior and decisions
Span Level - Tool calls, LLM requests, state transitions
Agent Lifecycle Stages
Every agent operation is tracked through five observable stages:
Thought - Data ingestion, context retrieval, information interpretation
Action - Planning processes, tool selection, decision-making
Execution - Task performance, API calls, external integrations
Reflection - Self-evaluation, learning signals, adaptation
Alignment - Trust validation, safety checks, policy enforcement
Captured Data
Agent state transitions and decision points
Tool invocations with inputs and outputs
LLM API calls with prompts and responses
Execution times and latency metrics
Error traces and exception handling
Custom metadata and tags
Detailed Setup
Installation
pip install fiddler-langgraphConfiguration
The SDK uses environment variables for zero-code configuration:
# Required
export FIDDLER_API_KEY="fid_..." # Your Fiddler API key
export FIDDLER_URL="https://app.fiddler.ai" # Fiddler instance URL
# Optional
export FIDDLER_PROJECT="my-agents" # Project name (auto-created)
export FIDDLER_ENVIRONMENT="production" # Environment tag
export OTEL_SERVICE_NAME="travel-agent" # Service identifierConfiguration via Code (alternative to environment variables):
from fiddler_langgraph import configure_fiddler
configure_fiddler(
api_key="fid_...",
url="https://app.fiddler.ai",
project="my-agents",
environment="production"
)Verify Installation
from fiddler_langgraph import verify_connection
# Check that Fiddler connection is working
if verify_connection():
print("✓ Connected to Fiddler successfully!")
else:
print("✗ Connection failed - check your API key and URL")Advanced Usage
Custom Spans
Add custom instrumentation for application-specific logic:
from fiddler_langgraph import trace_span
@trace_span(name="custom_retrieval", span_type="retrieval")
def my_custom_retrieval(query: str) -> dict:
# Your retrieval logic
results = vector_db.search(query)
return resultsAdding Metadata
Enrich traces with custom metadata:
from fiddler_langgraph import add_trace_metadata
# Add user context
add_trace_metadata({
"user_id": "user_123",
"session_type": "premium",
"feature_flags": ["new_ui", "advanced_mode"]
})Sampling Configuration
Control trace sampling for high-volume applications:
from fiddler_langgraph import configure_sampling
# Sample 10% of traces
configure_sampling(sample_rate=0.1)
# Or use adaptive sampling
configure_sampling(
sample_rate=0.5,
adaptive=True,
min_rate=0.1,
max_rate=1.0
)Error Handling
Automatic error capture with custom handlers:
from fiddler_langgraph import register_error_handler
def custom_error_handler(error, span):
# Custom error processing
span.set_attribute("error.custom_field", error.custom_data)
# Send to external monitoring
send_to_datadog(error)
register_error_handler(custom_error_handler)Example Applications
Multi-Agent Travel Planner
from langgraph.graph import StateGraph, END
from fiddler_langgraph import configure_fiddler
# Configure Fiddler (one-time setup)
configure_fiddler(
api_key="fid_...",
url="https://app.fiddler.ai",
project="travel-agents"
)
# Define your agent graph
class TravelState(TypedDict):
destination: str
budget: float
itinerary: list
# Research agent
def research_agent(state: TravelState):
# Agent logic - automatically traced
return {"research_complete": True}
# Booking agent
def booking_agent(state: TravelState):
# Agent logic - automatically traced
return {"bookings": [...]}
# Build graph
graph = StateGraph(TravelState)
graph.add_node("research", research_agent)
graph.add_node("booking", booking_agent)
graph.add_edge("research", "booking")
graph.add_edge("booking", END)
# Run - traces automatically sent to Fiddler
app = graph.compile()
result = app.invoke({"destination": "Paris", "budget": 5000})View complete example notebook →
Customer Support Agent with Tools
from langchain.tools import Tool
from langgraph.prebuilt import create_react_agent
# Define tools - calls automatically traced
tools = [
Tool(name="search_kb", func=search_knowledge_base),
Tool(name="create_ticket", func=create_support_ticket),
Tool(name="escalate", func=escalate_to_human)
]
# Create agent - instrumentation is automatic
agent = create_react_agent(model, tools)
# Run agent - full trace in Fiddler
response = agent.invoke({
"messages": [{"role": "user", "content": "My order is delayed"}]
})Viewing Your Data
After running your instrumented application:
Navigate to Fiddler UI -
https://app.fiddler.ai/projects/your-projectSelect "Agents" tab - View agent execution traces
Inspect hierarchical traces - Drill down from application → session → agent → span
Analyze patterns - Use analytics to identify bottlenecks and errors
Key Metrics Tracked
Latency: P50, P95, P99 response times across agents
Error Rate: Percentage of failed agent executions
Token Usage: LLM token consumption per agent/session
Tool Calls: Frequency and success rate of tool invocations
State Transitions: Agent decision path analysis
Troubleshooting
Traces Not Appearing
Check configuration:
from fiddler_langgraph import get_current_config
config = get_current_config()
print(config) # Verify API key, URL, projectVerify network connectivity:
curl https://app.fiddler.ai/api/v1/healthEnable debug logging:
import logging
logging.basicConfig(level=logging.DEBUG)High Latency from Instrumentation
The SDK uses asynchronous export to minimize overhead. If experiencing issues:
from fiddler_langgraph import configure_export
# Batch and compress spans
configure_export(
batch_size=100,
export_interval=5, # seconds
compression=True
)Missing Spans
Ensure you're using compatible LangGraph version:
pip install langgraph>=0.2.0Some custom graphs may need explicit instrumentation:
from fiddler_langgraph import instrument_graph
# Manually instrument if auto-instrumentation incomplete
instrument_graph(my_graph)OpenTelemetry Compatibility
The LangGraph SDK is built on OpenTelemetry Protocol (OTLP). You can:
Export traces to multiple backends simultaneously
Use custom OTEL collectors
Integrate with existing observability infrastructure
from fiddler_langgraph import add_otlp_endpoint
# Send to both Fiddler and Datadog
add_otlp_endpoint(
endpoint="https://datadog-otel.example.com",
headers={"DD-API-KEY": "..."}
)Related Integrations
Fiddler Evals SDK - Evaluate LangGraph agent quality offline
Python Client SDK - Additional monitoring capabilities
Migration Guides
From LangSmith
# Before (LangSmith)
import os
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_API_KEY"] = "ls_..."
# After (Fiddler - both can run simultaneously)
os.environ["FIDDLER_API_KEY"] = "fid_..."
os.environ["FIDDLER_URL"] = "https://app.fiddler.ai"
# Your LangGraph code remains unchangedFrom Manual Tracing
If you've built custom tracing, migration is simple:
# Before (manual)
import time
start = time.time()
result = my_agent.run()
duration = time.time() - start
log_to_system(duration, result)
# After (Fiddler SDK)
# Remove all manual timing/logging code
result = my_agent.run() # Automatic instrumentationAPI Reference
Full SDK documentation:
LangGraph SDK Reference - Complete class and method documentation
Last updated
Was this helpful?