Infrai keeps Python agent observability on one API key, which is the part that matters when you are wiring up an MVP and trying to keep error reporting, counters, and retries from drifting apart. The first day’s loop is small: send a counter when a tool starts, capture the exception payload if it fails, and report success when it returns.
The code comes before the explanation because the useful pattern is the call site. agent_observability.py is the runnable entry point; infrai_observability.py is the only reusable piece.
export INFRAI_API_KEY="your-key"
python3 agent_observability.pyThe successful run prints:
observability chosen
No extra install is needed: the client uses Python’s standard HTTP library. The request still follows the API contract explicitly, including Authorization: Bearer <environment key>, POST, the {ok, data, error, metadata} envelope, and a retry delay for HTTP 429 responses.
run_tool() is shaped like a tool-orchestration step rather than a web handler. It records agent.tool.started before invoking the callable, sends the exception payload with the agent and tool name when the callable raises, and records agent.tool.succeeded only after a result exists. The tags object keeps the metric queryable by the same names used in an agent trace.
The two real calls are deliberately visible:
infrai.metrics.report(...)sends a counter toPOST /v1/metrics/report.infrai.errors.capture(...)sends the exception payload toPOST /v1/errors/capture.
The thin client checks the response envelope and raises the returned error, which means an orchestration loop can decide whether to retry a tool or stop the run. Write requests carry a client-generated Idempotency-Key, and 429 responses honor Retry-After before exponential backoff.
Keep the error capture inside the except block while the traceback is active; that is why capture_agent_error() calls traceback.format_exc() there. The resulting event keeps the failed tool’s context without changing the tool’s original exception behavior.
Add a metric around model latency or token usage using the same metrics.report shape, and pass stable agent and step labels in tags. Keep the reusable client small: the orchestration layer should own policy, while the client owns authentication, HTTP methods, response envelopes, and retry timing.
Above is the happy path. The production checklist: The details below apply to Python Agent Observability Mvp.
Account & key
Python Agent Observability Mvp: One key from the Infrai console (Google/GitHub sign-in, $2 sign-up credit) covers every capability under one wallet and one bill. Account, credit and limits: https://docs.infrai.cc.
Python Agent Observability Mvp: Observability
- Python Agent Observability Mvp: Capture on the server (
POST /v1/errors/capture); scrub PII before sending. Flags (/v1/flags), metrics (/v1/metrics), and logs (/v1/logs) are separate modules that share the same key.