Skip to main content

AgentMetrics observability integration for CrewAI agents

Project description

agentmetrics-crewai

PyPI License: MIT

AgentMetrics integration for CrewAI. Instantiate the listener once at startup and every crew.kickoff() reports back to your dashboard automatically showing latency, cost, token counts, tool calls, and errors, with zero changes to your crew code.


Install

pip install agentmetrics-crewai

Quickstart

from agentmetrics_crewai import AgentMetricsListener

# register once at startup, covers all crews in the process
AgentMetricsListener(
    agent_id="my-crew",
    base_url="http://localhost:8099",
)

# Run your crew as normal
result = MyCrew().kickoff()

API

AgentMetricsListener(agent_id, base_url)

Parameter Default Description
agent_id "crewai-agent" Fallback label if the crew has no crew_name
base_url "http://localhost:8099" AgentMetrics server address

Instantiating the class auto-registers event handlers on the global crewai_event_bus with no further setup needed, and the listener handles concurrent kickoffs correctly via source_fingerprint tracking.

.flush(timeout=10.0)

Blocks until all in-flight HTTP requests complete. Call before process exit in scripts.


What gets tracked

Each kickoff() call emits one event to /v1/events on completion or failure:

Field Description
status success or failed
duration_ms Wall-clock kickoff duration
input_tokens / output_tokens Aggregated across all LLM calls
cache_read_tokens / cache_write_tokens Cache token counts
llm_calls Number of LLM requests in the kickoff
tool_calls / tool_errors Tool usage counts
tool_names Set of tools invoked
model Model name from the first LLM call
estimated_cost_usd Computed from token counts and model pricing
error First 500 chars of the error message on failure

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

agentmetrics_crewai-0.2.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

agentmetrics_crewai-0.2.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file agentmetrics_crewai-0.2.0.tar.gz.

File metadata

  • Download URL: agentmetrics_crewai-0.2.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for agentmetrics_crewai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a73122745cd66778fceb0e6c6a2ebf9cd68b053d724931865cd9693be09efc5f
MD5 b255aae91c64bf77f3931658475d5471
BLAKE2b-256 2c449a67eff16c22046737789b1c2ccd59c2f548259f096cd853ef9ff90ea833

See more details on using hashes here.

File details

Details for the file agentmetrics_crewai-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentmetrics_crewai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9dea8b4f02ac4fe8d3b381cb56ee55d6cb4b131aee0a1408db5458cae0a7f651
MD5 604fb6d5e143a0d732ae519a15fcd8ca
BLAKE2b-256 521a76a084d4b640cef7414dec342ee634155640fb7fa44e77b428559b3d4062

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