AI agent cost and failure monitoring — Sentry for AI agents
Project description
trakr-monitor
Observability SDK for AI agent workflows. Automatically captures Anthropic and OpenAI LLM calls with cost, tokens, latency, and tool use — sent to your Trakr dashboard.
Install
pip install trakr-monitor
# With Anthropic auto-instrumentation
pip install trakr-monitor[anthropic]
# With OpenAI auto-instrumentation
pip install trakr-monitor[openai]
Quick start
import trakr_monitor as trakr
import anthropic
trakr.init() # reads TRAKR_API_KEY
client = anthropic.Anthropic()
with trakr.start_run("daily-report") as run:
client.messages.create(
model="claude-sonnet-4-6",
max_tokens=256,
messages=[{"role": "user", "content": "Summarize logs"}],
)
trakr.flush() # blocking — call before sys.exit() in scripts
Decorator pattern
import trakr_monitor as trakr
trakr.init()
@trakr.track_agent(name="invoice-extractor")
def extract_invoice(document: str) -> dict:
return do_extraction(document)
Async functions are supported:
@trakr.track_agent(name="async-processor")
async def process_async(data: str) -> str:
return await call_llm(data)
Configuration
| Option | Default | Description |
|---|---|---|
api_key |
TRAKR_API_KEY env |
SDK API key (tk_live_...) |
endpoint |
https://app.trakr.run/api/ingest |
Ingest URL override |
batch_size |
10 |
Events per upload batch |
flush_interval_seconds |
2.0 |
Max time between uploads |
loop_detection_threshold |
5 |
Consecutive same-tool calls before loop_detected |
disabled |
False |
Disable all instrumentation |
debug |
False |
Log SDK activity to stdout |
Local development
import os
import trakr_monitor as trakr
trakr.init(
api_key="tk_live_testkey00000000000000000000000000",
endpoint=os.environ.get("TRAKR_INGEST_URL", "http://localhost:3000/api/ingest"),
)
API
trakr.init(...)
trakr.start_run(workflow_name, ...) -> Run # context manager
trakr.track_agent(name, metadata=None) # decorator
trakr.flush() # blocking flush
trakr.disable()
run.end(status="success" | "error", error_message=None)
run.set_metadata(key, value)
Tests
cd libs/sdk/python
pip install -e ".[dev]"
python -m pytest
python -m build
Documentation
Support
Questions or issues: support@trakr.run
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
trakr_monitor-0.1.2.tar.gz
(10.5 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
File details
Details for the file trakr_monitor-0.1.2.tar.gz.
File metadata
- Download URL: trakr_monitor-0.1.2.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52270f974218f144f4cb1a163b56541a961e3b18f976590b10943ec531d289e6
|
|
| MD5 |
e689d0225b0f63952e81b19d7a3491d4
|
|
| BLAKE2b-256 |
1ebd49f78ad6e79bc8f20d95487b6f18f7141b56821c4e05e9fedae9b6f5746d
|
File details
Details for the file trakr_monitor-0.1.2-py3-none-any.whl.
File metadata
- Download URL: trakr_monitor-0.1.2-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23540a1318d7a770c069d6ff323788f7304b2437b23d69cdfbe6448db5381e73
|
|
| MD5 |
36e5cf79a6fcdf31c9dc556ad38f8a19
|
|
| BLAKE2b-256 |
da67304f479c87790b999a8f7d2f4d26af466e0fdee1726ea136eaa3afe5cbc6
|