Lightweight LLM observability. SQLite-based tracing with zero infrastructure.
Project description
Lightweight LLM observability. Zero infrastructure.
One SQLite file. One pip install. Full tracing for any LLM application.
pip install llmtracex
Why llm-trace?
| Feature | Langfuse | LangSmith | llm-trace |
|---|---|---|---|
| Setup | Docker + PostgreSQL + Redis | Cloud account | pip install llmtracex |
| Infrastructure | 4 services | Managed | Zero |
| Storage | ClickHouse | Cloud | SQLite |
| Dependencies | Many | Many | Zero |
| Dashboard | Yes | Yes | Built-in (:7600) |
| Cost | Free/Paid | Paid | Free forever |
Quick Start
1. Decorate any function
from llm_trace import observe
@observe()
def my_pipeline(query: str) -> str:
docs = retrieve(query)
return generate(query, docs)
2. Wrap OpenAI / Anthropic SDKs
from llm_trace.wrappers import wrap_openai
import openai
client = wrap_openai(openai.OpenAI())
# Every call is traced automatically — tokens, cost, latency
response = client.chat.completions.create(model="gpt-4o", messages=[...])
3. LangChain / LangGraph (recommended)
from llm_trace.langchain import CallbackHandler
handler = CallbackHandler(trace_name="my-agent", session_id="chat-123")
result = graph.invoke(input, config={"callbacks": [handler]})
handler.flush()
# 1 invoke = 1 trace. All nodes captured automatically.
4. OpenTelemetry (LlamaIndex, Haystack, CrewAI, DSPy...)
from llm_trace.otel import install_otel
install_otel(instrumentors=["llama_index", "haystack"])
# Any OTEL-instrumented framework is now traced
5. Webhook (any language)
curl -X POST http://localhost:7601/api/ingest \
-H "Content-Type: application/json" \
-d '{"trace":{"name":"from-curl"}, "observations":[{"type":"generation","model":"gpt-4o","usage":{"input_tokens":100,"output_tokens":50}}]}'
6. Scores
from llm_trace import score
score("quality", 0.92, trace_id=handler.get_trace_id())
Dashboard
llm-trace dashboard
# or
python -c "from llm_trace import tracer; tracer.dashboard()"
# Custom port
llm-trace dashboard --port 8080
llm-trace dashboard -p 3000 --no-browser
Opens http://localhost:7600 with:
- Overview with tokens/cost/latency charts over time
- Trace list with search and filtering
- Tree view with expandable observations
- Graph view showing execution flow
- Per-trace stats (tokens, cost, latency, status)
- Delete individual traces or clear all
CLI
llm-trace stats # Summary
llm-trace list # Recent traces
llm-trace show <trace-id> # Detail view
llm-trace dashboard # Web UI
llm-trace clear # Delete all
llm-trace export > traces.json # Export
Architecture
┌─────────────┬──────────────┬───────────────┬──────────────┐
│ @observe() │ wrap_openai()│ CallbackHandler│ install_otel()│
│ any func │ wrap_anthropic│ LangChain/LG │ OTEL spans │
├─────────────┴──────────────┴───────────────┴──────────────┤
│ Tracer (singleton) │
│ background flush, contextvars │
├───────────────────────────────────────────────────────────┤
│ SQLite WAL (~/.llm-trace/) │
│ traces → observations → scores │
├───────────────────────────────────────────────────────────┤
│ Dashboard (:7600) │ CLI │ Webhook (:7601) │
└───────────────────────────────────────────────────────────┘
Data Model
Follows the Langfuse data model:
- Trace — one execution (1
graph.invoke()= 1 trace) - Observation — a step within a trace (generation, tool, retriever, agent, span, guardrail, embedding, event)
- Score — evaluation metric attached to a trace
Configuration
# Database location (default: ~/.llm-trace/traces.db)
export LLM_TRACE_DB_PATH=./my-traces.db
# Environment tag
export LLM_TRACE_ENVIRONMENT=production
# Release version
export LLM_TRACE_RELEASE=v1.2.3
Optional Dependencies
pip install llmtracex # Zero deps, @observe + wrappers + CLI
pip install llmtracex[langchain] # + LangChain CallbackHandler
pip install llmtracex[langgraph] # + LangChain + LangGraph
pip install llmtracex[otel] # + OpenTelemetry SpanProcessor
pip install llmtracex[webhook] # + FastAPI webhook router
pip install llmtracex[all] # Everything
License
MIT
Made with ❤️ from Mallorca by marcmayol
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
llmtracex-0.2.0.tar.gz
(42.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
llmtracex-0.2.0-py3-none-any.whl
(46.7 kB
view details)
File details
Details for the file llmtracex-0.2.0.tar.gz.
File metadata
- Download URL: llmtracex-0.2.0.tar.gz
- Upload date:
- Size: 42.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f073d5a5a1348906b2f7fb867826be13c273a0ab03303d6248fe40b72765e32
|
|
| MD5 |
000b2889d89aca2479cd01ad6176124d
|
|
| BLAKE2b-256 |
4dd0432d7eaf5412fee675144fe643c40a78dc9ffed8c65c0a0141510749dccb
|
File details
Details for the file llmtracex-0.2.0-py3-none-any.whl.
File metadata
- Download URL: llmtracex-0.2.0-py3-none-any.whl
- Upload date:
- Size: 46.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1e2352517ecaaba8103940e1472631fc97b24d9a9ee04eedf29c12b34c348cd
|
|
| MD5 |
8b29c79467ce39945593b9be1225c09d
|
|
| BLAKE2b-256 |
3d260e703dbba1ef3d0c6a9ff85cf1a39e2bbeb7b1c5e84525d053a471e93186
|