Why Use Traces
LLM requests are only part of the story. A typical AI agent workflow includes:- 🔍 Vector database searches for retrieval
- 🗄️ Database queries to fetch context
- 🌐 External API calls to tools and services
- ⚙️ Custom processing and validation logic
- 📊 Data transformations and formatting
- ✅ See the complete workflow, not just LLM calls
- ✅ Measure latency across your entire stack
- ✅ Debug issues in non-LLM components
- ✅ Understand the full cost of operations (time, API calls)
- ✅ Visualize traces alongside LLM requests in sessions
Quick Start
Trace API Endpoint
Helicone provides a REST API for logging custom traces:Endpoint
Headers
Request Body
Log the “request” and “response” of any operation:Common Trace Patterns
Database Query
Log database operations to track query performance:Vector Database Search
Track vector searches and embeddings:External API Call
Log calls to external services:Tool Execution
Log AI agent tool calls:Traces in Sessions
Combine traces with sessions to see your complete workflow:/research/search- Vector search trace/research/analyze- LLM request/research/save- Database write trace
Typed Trace API
For stricter type safety, use the typed trace endpoint:Endpoint
Request Body
Example
Trace Metadata
Add custom properties to traces for filtering and analysis:Performance Tracking
Traces include timing information to help you identify bottlenecks:OpenTelemetry Integration
Helicone also supports native OpenTelemetry traces:Best Practices
What to Trace
✅ Do trace:- Database queries (especially slow ones)
- External API calls
- Vector database searches
- Tool executions in agents
- Custom business logic with significant latency
- Operations that could fail or timeout
- Trivial in-memory operations
- Simple variable assignments
- Fast operations (<1ms)
- Operations with sensitive data (unless you sanitize it)
Trace Granularity
✅ Good granularity:Sensitive Data
Sanitize sensitive information before logging:Troubleshooting
Traces Not Appearing
Problem: Traces aren’t showing up in the dashboard. Solutions:- Verify API key is correct and has write permissions
- Check that request body matches the expected format
- Look for HTTP error responses (400, 401, 500)
- Ensure
resultRecorder.appendResults()is called
Traces Not in Sessions
Problem: Traces aren’t appearing in session timeline. Solutions:- Include all three session headers:
Helicone-Session-IdHelicone-Session-PathHelicone-Session-Name
- Use the same session ID as other requests in the session
- Verify paths follow the
/parent/childformat
Performance Impact
Problem: Logging traces is slowing down your application. Solutions:- Use async logging (don’t await the log call if possible)
- Batch multiple operations before logging
- Only log operations that are actually slow (>100ms)
- Consider sampling: only log a percentage of traces
Related Features
Sessions
Group traces and LLM requests into sessions
Custom Properties
Add metadata to traces for filtering and analysis
Requests
View traces alongside LLM requests
Manual Logger
Helicone SDK for easier trace logging
Questions?
Need help or have questions? We’re here to help:- Discord Community: Join our Discord server for quick help
- GitHub Issues: Report bugs or request features on GitHub
- Documentation: Check our full documentation for more guides
