agentmetrics-openai-agents
AgentMetrics integration for the OpenAI Agents SDK. Register one trace processor at startup and every agent run reports back to your dashboard showing latency, cost, token counts, tool calls, and errors, with zero changes to your agent code.
Install
pip install agentmetrics-openai-agents
Quickstart
from agents.tracing import add_trace_processor
from agentmetrics_openai_agents import AgentMetricsProcessor
# register once at startup, covers all agents in the process
add_trace_processor(AgentMetricsProcessor(
agent_id="my-openai-agent",
base_url="http://localhost:8099",
))
# Run your agents as normal
result = await Runner.run(my_agent, "Summarize this document")
API
AgentMetricsProcessor(agent_id, base_url)
| Parameter | Default | Description |
|---|---|---|
agent_id |
"openai-agent" |
Fallback label if the trace has no name attribute |
base_url |
"http://localhost:8099" |
AgentMetrics server address |
Implements TracingProcessor from agents.tracing. Pass to add_trace_processor() before running any agents.
.force_flush()
Blocks until all in-flight HTTP requests complete.
.shutdown()
Calls force_flush(). Called automatically when the process exits cleanly.
What gets tracked
Each agent trace emits one event to /v1/events when on_trace_end fires:
| Field | Description |
|---|---|
status |
success or failed |
duration_ms |
Wall-clock trace duration |
input_tokens / output_tokens |
Aggregated from all LLMSpanData spans |
cache_read_tokens / cache_write_tokens |
Cache token counts |
llm_calls |
Number of LLM spans in the trace |
tool_calls / tool_errors |
Counts from FunctionSpanData spans |
tool_names |
Set of function/tool names |
model |
Model name from the first LLM span output |
estimated_cost_usd |
Computed from token counts and model pricing |
error |
First 500 chars of the trace error on failure |
License
Metadata
Release files for agentmetrics-openai-agents 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agentmetrics_openai_agents-0.2.0.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentmetrics_openai_agents-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / agentmetrics_openai_agents-0.2.0.tar.gz
| Download URL | agentmetrics_openai_agents-0.2.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd319cbd51600b478601277b7120e71e5359d6aa3e6567936941b1e9648202d6
|
|
BLAKE2b-256 checksum How to use checksums |
f4b7c64fffbbe8d903ce4f44bed1681fbcf84ffa3e49cfb694339ba4b46360f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / agentmetrics_openai_agents-0.2.0-py3-none-any.whl
| Download URL | agentmetrics_openai_agents-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a32a3f0f51262993bca42595f28f91feff34c544e48c12fb10c65aa97b51dc21
|
|
BLAKE2b-256 checksum How to use checksums |
88df8df88af81123c0db28f6825d09424efe9d7e2403b1ecb0d4d40fd1091d52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|