trulens-core
Library to systematically track and evaluate LLM based applications.
What it is and what it does
TruLens is an instrumentation and evaluation framework for LLM-based applications built on OpenTelemetry. It decorates functions to capture structured traces of every step—retrieval, LLM calls, tool invocations—recording latency, tokens, and cost per operation. Once traces are collected, the package evaluates them using LLM judges that score and explain their reasoning, enabling you to identify where applications fail, compare versions, and measure quality tradeoffs against cost.
The package ships with seven agentic evaluators (LogicalConsistency, ExecutionEfficiency, PlanAdherence, ToolSelection, and others) and supports both inline evaluation as your app runs and batch evaluation over pre-collected datasets. Because tracing is OpenTelemetry-native, traces are portable to any OTLP-compatible backend—Jaeger, Grafana Tempo, Datadog—making it interoperable with existing observability infrastructure. Runtime dependencies include SQLAlchemy for storage, Pydantic for validation, and OpenTelemetry libraries for instrumentation.
Use it for:
- Instrument a RAG pipeline to trace retrieval, ranking, and generation steps, then score groundedness and context relevance per query.
- Compare two versions of an agent by running both against a dataset and measuring latency, token cost, and evaluation scores side-by-side.
- Debug agent failures by examining structured traces that show which tool was called, what arguments were passed, and where reasoning broke down.
- Evaluate agentic systems for plan quality and tool selection by running purpose-built judges that flag redundant steps or incorrect tool choices.
- Export traces to an existing observability backend (Datadog, Grafana) while running evaluations in TruLens without duplicating instrumentation.
- Batch-evaluate a historical dataset of app runs using the Run API to compute metrics offline and identify systematic quality issues.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Instruments LLM applications with OpenTelemetry-native tracing and evaluates them with LLM-based judges that explain their reasoning, capturing latency, cost, and quality per step.
Yes. TruLens is actively maintained, has no known vulnerabilities, and solves a real problem for LLM application teams: making agent behavior traceable and measurable. The OpenTelemetry foundation ensures portability, and the built-in evaluators are benchmarked against human annotations. Install it if you need to instrument and evaluate LLM apps; skip it if you only need basic logging.
Install
trulens-core on PyPI
pip
pip install trulens-coreuv
uv add trulens-corepoetry
poetry add trulens-coreInstalling trulens-core
Before you install
Low friction: pure Python wheel with 19 runtime dependencies including well-established libraries like SQLAlchemy, Pydantic, and OpenTelemetry. Active maintenance with release on 2026-08-14 and 3508 GitHub stars.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install trulens-core
from trulens.core.otel.instrument import instrument
from trulens.otel.semconv.trace import SpanAttributes
class MyRAG:
@instrument(
span_type=SpanAttributes.SpanType.RETRIEVAL,
attributes={
SpanAttributes.RETRIEVAL.QUERY_TEXT: "query",
SpanAttributes.RETRIEVAL.RETRIEVED_CONTEXTS: "return",
},
)
def retrieve(self, query: str) -> list:
pass
Requires Python 3.9 or later; LLM provider packages (e.g., trulens-providers-openai) must be installed separately for feedback evaluation.
Verify before relying
- Whether the package works with Python 3.14 in practice, given it is marked as Alpha status.
- Performance characteristics when evaluating large-scale batch runs with the Run API.
- Compatibility with OTLP backends beyond those mentioned (Jaeger, Grafana Tempo, Datadog).
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 19 — alembic, dill, importlib-resources, munch, nest-asyncio, numpy, opentelemetry-api, opentelemetry-proto, opentelemetry-sdk, packaging, pandas, pydantic, python-dotenv, requests, rich, sqlalchemy, trulens-otel-semconv, typing_extensions, wrapt |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 126,116/month — #11,789 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: trulens_core-2.13.0-py3-none-any.whl
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
trulensTruLens instruments LLM applications to trace…
permissive · top 15,000 on PyPI
judgevalJudgeval is an SDK for tracing and evaluating…
permissive · top 15,000 on PyPI
cleanlab-tlmCleanlab TLM scores the trustworthiness of LLM…
permissive · top 15,000 on PyPI
ragasRagas provides objective metrics, test data…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-openai-agentsAdds distributed tracing to OpenAI Agents…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-remouladeAdds distributed tracing instrumentation for…
permissive · top 5,000 on PyPI
azure-core-tracing-opentelemetryIntegrates Azure SDK clients with OpenTelemetry…
unclear · top 5,000 on PyPI
opentelemetry-instrumentation-sklearnAdds distributed tracing instrumentation to…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-celeryAdds distributed tracing and observability to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-llamaindexAdds distributed tracing to LlamaIndex…
permissive · top 5,000 on PyPI