Skip to main content
FTL provides multiple observability features to track agent performance and behavior.

Langfuse Tracing

Automatic tracing of all LiteLLM completion calls to Langfuse.

Activation

Set environment variables before running FTL:
Or export directly:

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
Langfuse does NOT trace Claude Code agent internals - only FTL’s direct LiteLLM calls.

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

The timer resets on each mark() call, so each measurement shows the time since the previous mark.

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:
Once output arrives, the heartbeat stops and agent output displays normally.
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

Use Langfuse in development for debugging individual calls. Use CloudWatch in production for aggregated session analysis.
Langfuse provides per-call token counts and costs. Monitor usage trends to optimize prompt engineering.
Combine StageTimer output with CloudWatch span data to identify bottlenecks in the orchestration pipeline.
Langfuse’s failure_callback captures failed LiteLLM calls. Check Langfuse for model errors vs application errors.

Integration Code

Enable all observability features: