Package com.google.adk.telemetry
Class Instrumentation.AgentInvocation
java.lang.Object
com.google.adk.telemetry.Instrumentation.ClosableTelemetryScope
com.google.adk.telemetry.Instrumentation.AgentInvocation
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- Instrumentation
public static final class Instrumentation.AgentInvocation
extends Instrumentation.ClosableTelemetryScope
AutoCloseable telemetry tracking scope for agent invocations.
-
Field Summary
Fields inherited from class com.google.adk.telemetry.Instrumentation.ClosableTelemetryScope
caughtError, closed, span, startTimeNanos, telemetryContext -
Constructor Summary
ConstructorsConstructorDescriptionAgentInvocation(InvocationContext ctx, BaseAgent agent, io.opentelemetry.context.Context parentContext) Constructs a newAgentInvocationtelemetry scope. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an event to the list of events tracked during this agent invocation.getCtx()Retrieves the invocation context associated with this agent invocation.protected voidHandles errors that occur while recording metrics for the agent invocation.protected voidrecordMetrics(Duration elapsed, @Nullable Throwable error) Records metrics for the agent invocation including duration, request size, response size, and workflow steps.Methods inherited from class com.google.adk.telemetry.Instrumentation.ClosableTelemetryScope
beforeSpanEnd, close, context, setError
-
Constructor Details
-
AgentInvocation
public AgentInvocation(InvocationContext ctx, BaseAgent agent, io.opentelemetry.context.Context parentContext) Constructs a newAgentInvocationtelemetry scope.- Parameters:
ctx- The invocation context of the agent execution.agent- The agent being invoked.parentContext- The OpenTelemetry parent context.
-
-
Method Details
-
getCtx
Retrieves the invocation context associated with this agent invocation.- Returns:
- The
InvocationContext.
-
addEvent
Adds an event to the list of events tracked during this agent invocation.- Parameters:
event- TheEventto add.
-
recordMetrics
Records metrics for the agent invocation including duration, request size, response size, and workflow steps.- 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 agent invocation.- Specified by:
handleMetricsErrorin classInstrumentation.ClosableTelemetryScope- Parameters:
e- The runtime exception encountered during metrics recording.
-