truera/trulens
OpenTelemetry-native Python SDK for tracing and evaluating RAG apps and agents
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
TruLens is a Python SDK embedded in the application, not an agent execution framework. The @instrument decorator turns instrumented calls into OpenTelemetry spans. Typed spans distinguish retrieval, generation, and tool calls; explicit attribute mappings can put a retrieval query and its returned contexts on the same span. OTLP export lets teams route the resulting traces to a compatible observability backend.
Evaluation is a separate layer over those records. A Metric pairs an implementation with Selector bindings that resolve its arguments from record inputs or span attributes. This is what lets a team score one retrieval context or tool step rather than pass only the final answer to a judge. LangChain/LangGraph and LlamaIndex integrations are packaged separately, as are evaluator providers. The root pyproject.toml uses poetry-core as the build backend and requires Poetry 2.0 or newer for its Poetry workflow; neither is an app-side instrumentation API.
Key Capabilities & Differentiators
For RAG, the triad separates answer relevance, context relevance, and groundedness, which helps distinguish a retrieval miss from an answer that ignores its evidence. Seven agent evaluators cover logical consistency, execution efficiency, plan adherence, plan quality, tool selection, tool calling, and tool quality. MCP spans can capture tool names, arguments, outputs, and latency. Per-step traces and version comparisons bring scores, latency, token usage, and cost into the same investigation.
Evaluations can run alongside the app or against existing data. The table-backed RunConfig example maps an input column, sets separate worker limits for app invocations and metric computation, and calls compute_metrics on the run. Provider packages cover OpenAI/Azure OpenAI, LiteLLM, Gemini, Bedrock, Snowflake Cortex, HuggingFace, LangChain models, and the OpenAI-compatible OrcaRouter gateway. Agent GPA caught 267 of 281 human-annotated errors on TRAIL/GAIA (95%, versus 55% for the baseline trace judge); that result is a benchmark reference, not a production acceptance threshold.
Trade-offs & Limitations
Against LangSmith, the strongest reason to pilot TruLens is control over in-process instrumentation, metric-to-span bindings, and the destination for exported traces. That flexibility creates setup work: teams must define span boundaries, verify that selectors still resolve the intended values after app changes, and own backend operations if they self-host. OTLP makes traces portable; it does not imply another backend can execute TruLens metrics or import its run workflow.
Inline judging provides earlier feedback but can add work while the app is serving requests; batch evaluation moves that work out of live traffic at the cost of delayed results. Pin judge models and rubrics for version comparisons, and calibrate against a human-reviewed sample before using scores as release gates. The MIT license permits commercial SDK use, but prompts, retrieved text, and tool arguments may be sensitive. Decide what to capture and retain, and what can be sent to a judge, before enabling broad collection.
Hardware & Deployment Guide
Start with pip install trulens, then add the provider package and any framework integration the app needs. Run tracing in the Python application and configure an OTLP destination if you want external export, such as to Jaeger or Grafana Tempo. Budget provider credentials, network access, and rate limits separately from trace ingestion. Running a batch after collection does not make it network-free if the metric calls a hosted judge; there is no universal GPU or VRAM requirement.
For upgrades, 2.14 added coding-agent instrumentation for Claude Code and Cursor workflows. Version 2.15 improved cross-HTTP trace continuity and preservation of GenAI message content across persistence and export. Version 2.16 adds metrics and Jury reliability metadata, improves handling of unparsable judge scores, and fixes cost accounting, batch evaluation, and tracing issues. It also removes Streamlit-in-Snowflake dashboard support, so teams using that dashboard need a replacement before upgrading.
RunConfig exposes separate invocation_max_workers and metric_max_workers settings.MCP span type can capture tool name, arguments, output, and latency.Python RAG and agent teams that need to pinpoint failures at individual steps, compare quality against latency and cost, and keep control of where traces go.
You need a turnkey managed platform, cannot modify application instrumentation, or only need final-answer scoring and have no use for step-level traces.
Quick Start & Installation
pip install trulensComparison vs. Top Agents & Frameworks Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| trulens ★ | 3.7k | +15 | Python | MIT | OpenTelemetry-native Python SDK for tracing and evaluating RAG apps and agents |
| langfuse | 38.2k | +282 | TypeScript | — | OpenTelemetry platform for agent tracing and evals, with an AI gateway |
| opik | 23.6k | +50 | Java | Apache-2.0 | Self-hostable observability platform for tracing and evaluating LLM and agent wo |
| rocketride-server | 19.9k | +22 | Python | MIT | C++ workflow engine for building and running extensible AI pipelines |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/truera/trulens.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about trulens
How do I instrument an existing Python RAG app without rewriting it?
@instrument with the RETRIEVAL span type and map the query and returned contexts to span attributes. Then bind a metric to those values through the Selector API. Add generation and tool spans where they help separate retrieval failures from answer or execution failures.Does TruLens need a GPU, and how should I size a batch run?
Can we use TruLens commercially and keep observability data in our own environment?
How should we choose between TruLens and LangSmith?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy