Skip to main content

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.

Coming soon on PyPI — not published yet. Use @trakr/monitor on npm for production today.

Install (when published)

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


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.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trakr_monitor-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file trakr_monitor-0.1.0.tar.gz.

File metadata

  • Download URL: trakr_monitor-0.1.0.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

Hashes for trakr_monitor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe525ec08bfcd3d5147de2980f3c4dfbb804d89f795328ef8c5a1ec5d6e3e3c0
MD5 7ca45a0d1b98ab142af835a8f4f9b7b7
BLAKE2b-256 2f52859a8c248e5c05833a77210c9ed5f03c293b021b8fdb29d0f5a59aba4b83

See more details on using hashes here.

File details

Details for the file trakr_monitor-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: trakr_monitor-0.1.0-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

Hashes for trakr_monitor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c985630095d6408cd5583ae46905e128b57c69cd1aeb4087b0defd43ceb025db
MD5 4abb5e3c3585a139a283bc9b5e298190
BLAKE2b-256 15be057bf3985834f0b397e663586410be3617ec73d8c9dca07c0d8bafc34ad1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page