Langfuse Tracing
Automatic tracing of all LiteLLM completion calls to Langfuse.Activation
Set environment variables before running FTL:Setup Function
Source: ftl/tracing.py:26-39
Langfuse tracing is opt-in via environment variables. Without credentials,
setup_langfuse() returns False and no tracing occurs.What Gets Traced
Langfuse captures:- Adversarial tester calls - Test generation from
ftl.planner - Diff review calls - Code review completions
- Q&A interactions - Any direct LiteLLM usage
Viewing Traces
Once configured, view traces in the Langfuse dashboard:1
Navigate to Langfuse
Go to your Langfuse project dashboard
2
Filter by session
Use session metadata to group related calls
3
Analyze performance
View token usage, latency, and costs per call
Stage Timer
Prints elapsed wall-clock time after each orchestrator stage.Implementation
Source: ftl/tracing.py:42-61
Usage Example
Output Format
The timer prints dimmed text with consistent formatting:Agent Heartbeat
Shows progress while waiting for the first byte of agent output.The Problem
Claude Code can take 10-15 seconds to start (cold start), which looks like a hang without feedback.The Solution
Source: ftl/tracing.py:64-100
Usage Pattern
Output Example
While waiting:The heartbeat runs in a daemon thread and updates every 5 seconds.
Configuration Summary
env var
Langfuse project public key (starts with
pk-lf-)env var
Langfuse project secret key (starts with
sk-lf-).ftlconfig
CloudWatch log group for structured tracing (see AWS Integration)
Tracing Comparison
Langfuse
Traces LiteLLM calls with token usage and cost tracking
CloudWatch
Structured JSON spans for stages, tools, and sessions
Stage Timer
Simple wall-clock timing for orchestrator stages
Heartbeat
User feedback during agent cold start
Best Practices
Development vs Production
Development vs Production
Use Langfuse in development for debugging individual calls. Use CloudWatch in production for aggregated session analysis.
Cost Monitoring
Cost Monitoring
Langfuse provides per-call token counts and costs. Monitor usage trends to optimize prompt engineering.
Performance Analysis
Performance Analysis
Combine StageTimer output with CloudWatch span data to identify bottlenecks in the orchestration pipeline.
Error Tracking
Error Tracking
Langfuse’s
failure_callback captures failed LiteLLM calls. Check Langfuse for model errors vs application errors.