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
-
recordAgentRequestSize
public static void recordAgentRequestSize(String agentName, @Nullable com.google.genai.types.Content userContent) Records the size of the agent request. -
recordAgentResponseSize
-
recordAgentWorkflowSteps
-
recordToolExecutionDuration
-
recordToolRequestSize
-
recordToolResponseSize
-