Skip to main content

LLM Observability

Hitler provides comprehensive observability for LLM interactions, including tracing, metrics collection, cost tracking, and A/B testing for prompt optimization.

Why Observability Matters

Cost Control

Track token usage and costs across models to optimize spending

Performance Monitoring

Monitor latency percentiles and identify bottlenecks

Quality Assurance

A/B test prompt variations to improve response quality

Debugging

Trace individual requests through the system

LLM Tracer

The LLMTracer class provides detailed tracing for all LLM calls.

Basic Usage

Using the withTracing Wrapper

For cleaner code, use the withTracing helper:

Trace Properties

Each trace captures:

Custom Tracer Configuration

Metrics Collection

Getting Metrics

Metrics Structure

Cost Tracking

Built-in cost configuration for common models:

A/B Testing Framework

Test different prompt variations to optimize response quality.

Creating an Experiment

Getting Variant for Users

Recording Results

Analyzing Results

Experiment Lifecycle

Integration Example

Complete integration in a chat service:

Dashboard Queries

Cost by Organization

Model Performance Comparison

A/B Test Winner Detection

Best Practices

1

Always trace LLM calls

Use withTracing wrapper for all LLM interactions
2

Set meaningful prompt versions

Track which prompt version produced each response
3

Run experiments with sufficient sample size

At least 100 samples per variant for statistical significance
4

Monitor costs regularly

Set up alerts for unexpected cost increases
5

Archive old traces

Move traces older than 90 days to cold storage

Notification Deduplication

The TaskNotificationDedupService (apps/api/src/modules/jobs/task-notification-dedup.service.ts) prevents duplicate notifications from being sent for the same event. It uses Redis-based dedup keys to ensure that repeated events (e.g., multiple overdue checks for the same task) only generate one notification within a configurable window. This is critical for cron-driven jobs that run frequently and may process the same tasks multiple times.
LLM traces may contain sensitive user input. Ensure proper access controls and consider truncating input in traces for privacy compliance.