Lightweight file-based OTel tracing for AI agent frameworks — with built-in viewer
Project description
minitrail
Work in progress — use at your own risk.
Lightweight, file-based OpenTelemetry tracing for AI agent frameworks — with an optional built-in web viewer.
minitrail captures every LLM call your agents make and writes one JSON file per trace to disk. No collector, no database, no infrastructure. Optionally generates live human-readable Markdown reports with token counts and cost breakdowns.
Features
- One-call setup —
from minitrail import setup; provider = setup()before your framework imports - File-per-trace JSON export — each trace is a self-contained JSON file under
logs/json/ - Live Markdown export — human-readable
.mdfiles with messages, token counts, cost tables, and extracted images - Built-in web viewer —
minitrail servelaunches a FastAPI app with an interactive span waterfall - Auto-instrumentation — automatically patches LangChain, LlamaIndex, CrewAI, and Haystack via OpenInference
- Cost tracking — built-in pricing for Anthropic, OpenAI, Amazon Nova, Mistral, and Meta Llama models
Installation
pip install "minitrail" # Strands Agents
pip install "minitrail[langchain]" # LangChain / LangGraph
pip install "minitrail[crewai]" # CrewAI
pip install "minitrail[llama-index]" # LlamaIndex
pip install "minitrail[all]" # all supported frameworks
Quick start
setup() must be called before importing your framework so the instrumentor can patch it.
from minitrail import setup
provider = setup(
service_name="my-agent",
logs_dir="logs",
markdown=True, # also write human-readable Markdown
)
# --- import your framework AFTER setup() ---
from langchain.chat_models import init_chat_model
# ... your agent code ...
provider.force_flush()
provider.shutdown()
Traces are written to:
logs/
json/ # machine-readable JSON (always)
human_readable/ # Markdown + images (when markdown=True)
images/
Viewing traces
When markdown=True is set, traces are written as Markdown files under logs/human_readable/. These can be read directly in any text editor, terminal, or Markdown viewer — no server required.
For an interactive experience with span waterfall, collapsible details, and per-model cost breakdowns, launch the built-in web viewer:
minitrail serve logs/
minitrail serve logs/ --port 9000
Or run as a module:
python -m minitrail serve logs/
API reference
setup()
setup(
service_name: str = "minitrail",
logs_dir: str = "logs",
markdown: bool = False,
frameworks: list[str] | None = None,
instrument: bool = True,
) -> TracerProvider
| Parameter | Description |
|---|---|
service_name |
Value for the service.name OTel resource attribute |
logs_dir |
Root directory for trace output |
markdown |
Also write human-readable .md files |
frameworks |
List of frameworks to instrument (e.g. ["langchain"]). None = auto-detect all |
instrument |
Set to False to skip framework instrumentation |
Returns the configured TracerProvider. Call provider.force_flush() and provider.shutdown() when done.
Exporters
For advanced use, the exporters can be used directly with any OpenTelemetry TracerProvider:
FilePerTraceExporter(directory)— writes one JSON file per traceMarkdownTraceExporter(directory)— writes live Markdown reports
Examples
The examples/ directory contains complete working examples with LangGraph, CrewAI, and Strands Agents. All examples use Amazon Bedrock (Nova Pro + Claude Opus) and require AWS credentials.
Running from the repo
python -m venv .venv && source .venv/bin/activate
Strands Agents:
pip install -e . strands-agents
python examples/example_strands.py
LangGraph:
pip install -e ".[langchain]" langchain langchain-aws langgraph
python examples/example_langgraph.py
CrewAI:
pip install -e . "crewai[bedrock]" openinference-instrumentation-crewai
python examples/example_crewai.py
Then view the traces. Look into ./logs/human_readable or use the web UI:
minitrail serve ./logs
License
MIT
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
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
File details
Details for the file minitrail-0.2.1.tar.gz.
File metadata
- Download URL: minitrail-0.2.1.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a74f970f56f13071a2646819cd9651e8e5d387fc0787222c9d4b6a56970d22f
|
|
| MD5 |
08476e714f772589499df88847b70892
|
|
| BLAKE2b-256 |
2fc44df42d83457bad87e80ab92543227e3bed78441dc350fc558fb87378be11
|
File details
Details for the file minitrail-0.2.1-py3-none-any.whl.
File metadata
- Download URL: minitrail-0.2.1-py3-none-any.whl
- Upload date:
- Size: 29.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
100196e3ae70b8123776bf2d3e761bbfe62e798bce9a3cbe1d155d14363cd71f
|
|
| MD5 |
73b5845af4977a67a0f4962355904dbd
|
|
| BLAKE2b-256 |
8a98ae23b943b9ae4d5f461669ef613539806640bd8ad90b2def5e802bc2c297
|