xtrace
xtrace is a lightweight, self-hosted observability backend for AI/LLM applications. It collects traces, observations, and time-series metrics to help you diagnose latency, cost, quality, and failure patterns in production.
Running
Dependencies: PostgreSQL.
Environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL |
✓ | — | PostgreSQL connection string |
API_BEARER_TOKEN |
✓ | — | Protects all API endpoints |
BIND_ADDR |
127.0.0.1:8742 |
Listen address | |
DEFAULT_PROJECT_ID |
default |
Project id for ingested data | |
XTRACE_PUBLIC_KEY |
— | Langfuse BasicAuth compatibility | |
XTRACE_SECRET_KEY |
— | Langfuse BasicAuth compatibility | |
RATE_LIMIT_QPS |
20 |
Per-token query rate limit | |
RATE_LIMIT_BURST |
40 |
Per-token burst cap |
Also accepts legacy names LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY.
DATABASE_URL=postgresql://user@localhost:5432/xtrace \
API_BEARER_TOKEN=secret \
Health check:
HTTP API
All endpoints except /healthz require:
Authorization: Bearer $API_BEARER_TOKEN
Traces
POST /v1/l/batch — Batch ingest traces and observations.
GET /api/public/traces — Paginated trace list.
GET /api/public/traces/:traceId — Single trace detail.
GET /api/public/metrics/daily — Daily aggregated metrics.
Metrics (Time-Series)
POST /v1/metrics/batch — Write time-series metrics.
GET /api/public/metrics/names — List all metric names.
GET /api/public/metrics/query — Query time-series with downsampling.
| Parameter | Values | Default |
|---|---|---|
name |
metric name (required) | — |
from / to |
ISO8601 timestamps | last 1 hour |
labels |
JSON label filter | — |
step |
1m 5m 1h 1d |
1m |
agg |
avg max min sum last p50 p90 p99 |
avg |
group_by |
label key to split series by | — |
Example — p99 latency grouped by model:
Rust SDK (xtrace-client)
[]
= "0.0.12"
use ;
async
tracing Integration
Enable the tracing feature to automatically push metrics from tracing events and span durations — no manual push_metrics calls needed:
= { = "0.0.12", = ["tracing"] }
use ;
use SubscriberExt;
use SubscriberInitExt;
let client = new?;
registry
.with
.with
.init;
// Any event with metric= and value= is auto-pushed:
info!;
// Span durations are auto-reported as span_duration with a span_name label:
let _span = info_span!.entered;
Frontend Dashboard
A React dashboard (Vite + shadcn/ui) is included in the frontend/ directory.
VITE_XTRACE_BASE_URL=http://127.0.0.1:8742 \
VITE_XTRACE_API_TOKEN=your_token \
&&
Features: trace list, trace detail viewer with observation tree, and a metrics dashboard.