Package com.google.adk.telemetry
Class Metrics
java.lang.Object
com.google.adk.telemetry.Metrics
Utility class for recording OpenTelemetry metrics within the ADK.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidrecordAgentInvocationDuration(String agentName, Duration duration, @Nullable Throwable error) Records the duration of the agent invocation.static voidrecordAgentRequestSize(String agentName, @Nullable com.google.genai.types.Content userContent) Records the size of the agent request.static voidrecordAgentResponseSize(String agentName, @Nullable List<Event> events) Records the size of the agent response by extracting content from events.static voidrecordAgentWorkflowSteps(String agentName, List<Event> events) Records the number of steps in the agent workflow by counting the number of events.static voidrecordToolExecutionDuration(String toolName, String agentName, Duration duration, @Nullable Throwable error) Records the duration of the tool execution.static voidRecords the size of the tool request.static voidrecordToolResponseSize(String toolName, String agentName, @Nullable Event responseEvent) Records the size of the tool response.static voidsetMeterForTesting(io.opentelemetry.api.metrics.Meter meter) Sets the OpenTelemetry Meter to be used for metrics.
-
Method Details
-
setMeterForTesting
public static void setMeterForTesting(io.opentelemetry.api.metrics.Meter meter) Sets the OpenTelemetry Meter to be used for metrics. This is for testing purposes only. -
recordAgentInvocationDuration
public static void recordAgentInvocationDuration(String agentName, Duration duration, @Nullable Throwable error) Records the duration of the agent invocation. -
recordAgentRequestSize
public static void recordAgentRequestSize(String agentName, @Nullable com.google.genai.types.Content userContent) Records the size of the agent request. -
recordAgentResponseSize
Records the size of the agent response by extracting content from events. -
recordAgentWorkflowSteps
Records the number of steps in the agent workflow by counting the number of events. -
recordToolExecutionDuration
public static void recordToolExecutionDuration(String toolName, String agentName, Duration duration, @Nullable Throwable error) Records the duration of the tool execution. -
recordToolRequestSize
public static void recordToolRequestSize(String toolName, String agentName, Map<String, Object> functionArgs) Records the size of the tool request. -
recordToolResponseSize
public static void recordToolResponseSize(String toolName, String agentName, @Nullable Event responseEvent) Records the size of the tool response.
-