|
|
ADK Agent Monitoring with Custom Metrics
Author: Venkata Sudhakar
Production ADK agents need observability beyond basic logging. Custom Cloud Monitoring metrics let you track what matters to the business - how many tool calls succeed, how often the agent escalates to a human, and what the average response latency is per agent type. These metrics feed into dashboards and alerting policies.
ShopMax India runs five specialised agents in production: a product recommendation agent, a returns agent, a pricing agent, a logistics agent, and an escalation agent. Custom metrics help the operations team see which agents are under load, which are failing silently, and where to focus optimisation effort.
The below example shows how to wrap an ADK agent runner with Cloud Monitoring metric instrumentation.
It gives the following output,
Agent: returns_agent, Latency: 1.84s, Tools: 2
I have initiated the return for order ORD-9182. A pickup will be scheduled
within 48 hours. You will receive Rs 4,999 refund within 5-7 business days.
The below example shows how to create a Cloud Monitoring alerting policy that fires when agent latency exceeds a threshold.
It gives the following output,
Alert policy created: projects/shopmax-india/alertPolicies/1234567890
Alert will fire when returns_agent p50 latency exceeds 3.0s for 60 seconds
Custom metrics give ShopMax India visibility into agent performance at the business level. When the returns agent starts taking longer than 3 seconds on average, the operations team is alerted before customers notice. The tool_calls_per_request metric also helps identify when agents are over-calling external services, which directly impacts API costs and response quality.
|
|