xtrace
xtrace is a server-side component for AI/LLM observability that collects, stores, and queries traces/observations/metrics to help you diagnose latency, cost, quality, and failure patterns in production.
This crate is currently published as a binary (executable service) (only src/main.rs), so it does not provide a Rust SDK API that can be imported as a dependency. You can deploy and call it as an HTTP service.
Running
Dependencies: PostgreSQL.
Environment variables:
DATABASE_URL (required)
API_BEARER_TOKEN (required, protects the API)
BIND_ADDR (optional, default 127.0.0.1:8742)
DEFAULT_PROJECT_ID (optional, default default)
XTRACE_PUBLIC_KEY (optional, for Langfuse public API BasicAuth compatibility)
XTRACE_SECRET_KEY (optional, for Langfuse public API BasicAuth compatibility)
RATE_LIMIT_QPS (optional, default 20, per-token query rate limit QPS)
RATE_LIMIT_BURST (optional, default 40, per-token query rate limit burst cap)
Compatibility:
Also supports legacy names LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY.
Start:
DATABASE_URL=postgresql://xinference@localhost:5432/xtrace \
API_BEARER_TOKEN=... \
Health check:
HTTP API (Core Routes)
Except /healthz, all other endpoints require a Bearer token:
Authorization: Bearer $API_BEARER_TOKEN
POST /v1/l/batch
Batch ingest events.
Request body structure (simplified):
trace (optional) + observations (array)
GET /api/public/traces
Paginated trace query.
GET /api/public/traces/:traceId
Fetch a single trace's details.
GET /api/public/metrics/daily
Query daily aggregated metrics.
Nebula Integration (Metrics)
To support Nebula reporting GPU/node metrics (time-series metrics), xtrace provides additional metrics write and query endpoints.
Note: The current implementation works in single-tenant/single-project mode; all written metrics go to DEFAULT_PROJECT_ID and environment is fixed to default.
Write
POST /v1/metrics/batch
Request body:
Example:
NOW=
Query
GET /api/public/metrics/names
Returns all metric names under the current project:
GET /api/public/metrics/query
Parameters:
- name (required)
- from/to (optional, ISO8601; default last 1 hour)
- labels (optional, JSON string; backend filters with
labels @> ...) - step (optional: 1m/5m/1h/1d; default 1m)
- agg (optional: avg/max/min/sum/last; default avg)
Example:
Example:
Rust SDK (xtrace-client)
The repository includes an xtrace-client crate (HTTP SDK, based on reqwest).
[]
= "0.0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
Example:
use ;
async
The xtrace crate is positioned as a server-side component; splitting the SDK separately avoids pulling server-side dependencies (axum/sqlx) into client applications.