Prerequisites
- Python 3.8 or higher
- Gentrace API key
- OpenAI API key (or other LLM provider credentials)
Installation
Configuration
To enable Gentrace tracing with LangGraph, you need to set specific environment variables before importing any LangChain or LangGraph modules:index.py
The OpenTelemetry environment variables must be set before importing
LangChain or LangGraph modules. Setting them after imports will not
enable tracing.
Usage Example
Here’s a complete example showing how to trace a LangGraph agent with Gentrace:index.py
Environment Variables
Set these environment variables in your.env
file:
.env
How It Works
Gentrace captures LangGraph traces by:- Intercepting LangSmith traces: The OTEL environment variables redirect LangSmith’s built-in tracing to OpenTelemetry
- Capturing via OpenTelemetry: Gentrace’s OTEL integration automatically collects these traces
- Organizing with interactions: The
@interaction
decorator groups related agent executions
Advanced Usage
Custom Agent Configurations
You can trace more complex agent setups with custom configurations:advanced_agent.py
Multiple Agent Coordination
Track complex multi-agent systems:multi_agent.py