Skip to content

AI Agent Observability: Add Logging, Tracing, and Monitoring to Your Python Agents

A luminous agent cube at the center of concentric radar-like telemetry rings, streams of log glyphs orbiting outward, one amber blip standing out on a ring

Every article about AI agent observability tells you to buy a platform. Dynatrace. Arize. Galileo. They're great tools — if you have an enterprise budget and a dedicated observability team.

If you're a developer deploying autonomous agents in Python, you need observability that ships with your agent, not a separate SaaS subscription. Here's how to build it.

What "observability" means for an AI agent

Traditional service AI agent
Request latency Agent run duration
Error rate Tool call failures, LLM refusals
Throughput Runs per day, tokens consumed
Log lines Agent reasoning traces

The simplest observability: structured logging

import json, time, os
from datetime import datetime

def log(event_type: str, **kwargs):
    entry = {"timestamp": datetime.utcnow().isoformat(), "event": event_type, **kwargs}
    print(json.dumps(entry))

def handler(event, context):
    run_id = os.urandom(4).hex()
    start = time.time()
    log("agent.start", run_id=run_id, goal=event.get("goal", ""))
    try:
        result = run_agent(event.get("goal", ""))
        log("agent.complete", run_id=run_id, duration_sec=round(time.time()-start, 2),
            status="success", result=result)
        return {"ok": True, "run_id": run_id}
    except Exception as e:
        log("agent.error", run_id=run_id, error=str(e))
        raise

Tool call tracing

def traced_tool_call(tool_name, args, run_id):
    start = time.time()
    log("tool.call", run_id=run_id, tool=tool_name, args=args)
    try:
        result = execute_tool(tool_name, args)
        log("tool.result", run_id=run_id, tool=tool_name,
            duration_ms=int((time.time()-start)*1000))
        return result
    except Exception as e:
        log("tool.error", run_id=run_id, tool=tool_name, error=str(e))
        raise
agent.start agent.start at 0 ms tool.call — fetch_arxiv tool.call — fetch_arxiv: 620 ms 620 ms tool.call — query_db tool.call — query_db: 85 ms 85 ms llm.call — gpt-4o summarize llm.call — gpt-4o summarize: 2100 ms 2100 ms tool.call — send_email tool.call — send_email: 340 ms 340 ms agent.complete — 3.4 s agent.complete — 3.4 s at 3400 ms 0 s1 s2 s3 s
What the structured logs above reconstruct: one traced agent run as a waterfall. The LLM call dominates the runtime — without per-event timing you would never know.

Built-in observability with HollowHost

Metric HollowHost dashboard DIY logs
Run history ✅ Auto-tracked You build it
Duration per run ✅ Dashboard You compute it
Token usage ✅ Per-run tracking You add code
Log streaming ✅ Real-time CLI You pipe logs
hollowhost runs logs <ai-job-id> <run-id>

When to use a platform vs DIY

DIY (this article) Platform (LangSmith, Arize)
Cost $0 $50-500+/month
Setup time 30 minutes 1-2 days
Custom metrics Unlimited Limited
Best for 1-5 agents, custom needs 10+ agents, teams

Start with DIY. Upgrade to a platform when you need shared dashboards.


Deploy agents with built-in observability. Every run is logged automatically. Start on HollowHost — free tier included.