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.1.tar.gz
(10.4 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.1.tar.gz.
File metadata
- Download URL: trakr_monitor-0.1.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c8278e69d154bd19c00debecbf3ded6f9be71cc546da5e398d91f1fec53bc57
|
|
| MD5 |
0fb890f8db31206717fe16809339fd1d
|
|
| BLAKE2b-256 |
4f8288425b86adcec201db9e0ca2db55c6497a0c9cda80701aa96a5416dfc502
|
File details
Details for the file trakr_monitor-0.1.1-py3-none-any.whl.
File metadata
- Download URL: trakr_monitor-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.7 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 |
cfb0d8ed63e9105ace1b1338008241428b3b22f88a98be50a0a4aca7a4690ae8
|
|
| MD5 |
0efb3607b511256cd4d74a07ed3eda32
|
|
| BLAKE2b-256 |
4716d1de5a4dc8f1265578b0a16b835ca86c07d5d9fb2e6c7dcbd0df84176af0
|