Package com.google.adk.telemetry
Class Instrumentation.ToolExecution
java.lang.Object
com.google.adk.telemetry.Instrumentation.ClosableTelemetryScope
com.google.adk.telemetry.Instrumentation.ToolExecution
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- Instrumentation
public static final class Instrumentation.ToolExecution
extends Instrumentation.ClosableTelemetryScope
AutoCloseable telemetry tracking scope for tool executions.
-
Field Summary
Fields inherited from class com.google.adk.telemetry.Instrumentation.ClosableTelemetryScope
caughtError, closed, span, startTimeNanos, telemetryContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidTraces the tool execution attributes on the span before it ends.protected voidHandles errors that occur while recording metrics for the tool execution.protected voidrecordMetrics(Duration elapsed, @Nullable Throwable error) Records metrics for the tool execution including duration, request size, and response size.Methods inherited from class com.google.adk.telemetry.Instrumentation.ClosableTelemetryScope
close, context, setError
-
Constructor Details
-
ToolExecution
public ToolExecution(BaseTool tool, BaseAgent agent, Map<String, Object> functionArgs, io.opentelemetry.context.Context parentContext) Constructs a newToolExecutiontelemetry scope.- Parameters:
tool- The tool being executed.agent- The agent invoking the tool.functionArgs- The arguments passed to the tool.parentContext- The OpenTelemetry parent context.
-
-
Method Details
-
beforeSpanEnd
protected void beforeSpanEnd()Traces the tool execution attributes on the span before it ends.- Overrides:
beforeSpanEndin classInstrumentation.ClosableTelemetryScope
-
recordMetrics
Records metrics for the tool execution including duration, request size, and response size.- Specified by:
recordMetricsin classInstrumentation.ClosableTelemetryScope- Parameters:
elapsed- The total execution duration.error- The exception thrown during execution, if any.
-
handleMetricsError
Handles errors that occur while recording metrics for the tool execution.- Specified by:
handleMetricsErrorin classInstrumentation.ClosableTelemetryScope- Parameters:
e- The runtime exception encountered during metrics recording.
-