Observed since 20 Oct, 22:48 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Monitoring SDK for AI agents built with Google ADK
A lightweight monitoring SDK for AI agents built with Google ADK. Track agent executions, tool calls, and performance metrics in real-time with minimal code changes.
@traceable decoratorpip install agentops-monitor
For agent-to-agent (A2A) monitoring support:
pip install agentops-monitor[a2a]
Create a .env file in your project root:
AGENTOPS_API_KEY="your-api-key-here"
AGENTOPS_PROJECT_ID="your-project-id"
AGENTOPS_BASE_URL="http://localhost:8000" # Optional, defaults to production
Getting Your API Key:
from google.adk.agents import Agent
from agentops_monitor import monitor_agent
import os
# Create your agent
agent = Agent(
name="MyAgent",
model="gemini-2.5-flash",
instruction="You are a helpful assistant."
)
# Wrap it with monitoring
api_key = os.getenv("AGENTOPS_API_KEY")
monitored_agent = monitor_agent(agent, api_key)
# Use normally - monitoring happens automatically!
result = monitored_agent.run("What is the weather today?")
Open the AgentOps Monitor dashboard to see:
| Variable | Required | Default | Description |
|---|---|---|---|
AGENTOPS_API_KEY | Yes | - | Your API key from the dashboard |
AGENTOPS_PROJECT_ID | Yes | - | Project ID from the dashboard |
AGENTOPS_BASE_URL | No | Production URL | Backend URL (use http://localhost:8000 for local) |
from agentops_monitor.client import AgentOpsClient
client = AgentOpsClient(
api_key="your-api-key",
project_id="your-project-id",
base_url="http://localhost:8000"
)
from google.adk.agents import Agent
from agentops_monitor import monitor_agent
agent = Agent(name="SearchAgent", model="gemini-2.5-flash")
monitored_agent = monitor_agent(agent, api_key="your-key")
# All agent calls are now traced
response = monitored_agent.run("Search for Python tutorials")
from google.adk.runners import Runner
from agentops_monitor import monitor_runner
runner = Runner(app=app, session_service=session_service)
monitored_runner = monitor_runner(runner, api_key="your-key")
# Runner execution is now traced
for event in monitored_runner.run(user_id="user123", session_id="session456", new_message=message):
print(event)
from google.adk.tools import google_search
from agentops_monitor import wrap_tool
# Wrap individual tools to track their usage
wrapped_search = wrap_tool(google_search)
agent = Agent(
name="SearchAgent",
tools=[wrapped_search], # Use wrapped tool
model="gemini-2.5-flash"
)
from agentops_monitor import traceable
@traceable(name="data_processing")
def process_data(data):
# Your custom logic here
result = transform(data)
return result
# Function calls are automatically traced
result = process_data(my_data)
from google.adk.agents import Agent
from google.adk.apps import App
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.adk.tools import google_search
from google.genai import types
from agentops_monitor import monitor_agent, monitor_runner, wrap_tool
import os
from dotenv import load_dotenv
load_dotenv()
# Wrap tools
wrapped_search = wrap_tool(google_search)
# Create and monitor agent
agent = Agent(
name="SearchAgent",
model="gemini-2.5-flash",
tools=[wrapped_search],
instruction="You are a search specialist."
)
agent = monitor_agent(agent, os.getenv("AGENTOPS_API_KEY"))
# Create app and runner
app = App(name="SearchApp", root_agent=agent)
session_service = InMemorySessionService()
runner = Runner(app=app, session_service=session_service)
runner = monitor_runner(runner, os.getenv("AGENTOPS_API_KEY"))
# Run with monitoring
message = types.Content(parts=[types.Part(text="What is AI?")], role="user")
for event in runner.run(user_id="user123", session_id="session456", new_message=message):
if hasattr(event, "content") and event.content:
print(event.content)
The SDK requires a backend server to store and visualize traces. You have two deployment options:
# Clone the repository
git clone https://github.com/yourusername/agentops-monitor.git
cd agentops-monitor
# Start with Docker Compose
docker-compose up -d
This starts:
http://localhost:8000http://localhost:3000# Install dependencies
cd backend
pip install -r requirements.txt
# Set up database
export DATABASE_URL="postgresql://user:pass@localhost:5432/agentops"
# Run migrations
alembic upgrade head
# Start server
uvicorn main:app --host 0.0.0.0 --port 8000
See the Backend Documentation for detailed deployment instructions.
google-adk>=1.13.0)monitor_agent(agent, api_key, project_id=None, base_url=None)Wraps an ADK agent with monitoring capabilities.
Parameters:
agent (Agent): The ADK agent to monitorapi_key (str): Your AgentOps API keyproject_id (str, optional): Project ID (defaults to env var)base_url (str, optional): Backend URL (defaults to env var)Returns: Monitored agent instance
monitor_runner(runner, api_key, project_id=None, base_url=None)Wraps an ADK runner with monitoring capabilities.
Parameters:
runner (Runner): The ADK runner to monitorapi_key (str): Your AgentOps API keyproject_id (str, optional): Project ID (defaults to env var)base_url (str, optional): Backend URL (defaults to env var)Returns: Monitored runner instance
wrap_tool(tool)Wraps an ADK tool to track its usage.
Parameters:
tool: The ADK tool to wrapReturns: Wrapped tool instance
@traceable(name=None, **kwargs)Decorator for custom function tracing.
Parameters:
name (str, optional): Custom span name (defaults to function name)**kwargs: Additional metadata to attach to the traceExample:
@traceable(name="custom_operation", category="data")
def my_function(x):
return x * 2
Make sure you've set the API key in your .env file or environment:
export AGENTOPS_API_KEY="your-key-here"
Verify your backend is running and accessible:
curl http://localhost:8000/health
AGENTOPS_BASE_URL points to the correct backendContributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.3 | 3 Dec 2025 | 8 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 22:48 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:e797b126b4388329b4a839c5be46a35461a9b51ece502560e254732092389121