Class Instrumentation
java.lang.Object
com.google.adk.telemetry.Instrumentation
Unified context manager utility class for agent and tool execution telemetry in ADK.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAutoCloseable telemetry tracking scope for agent invocations.static classBase class for AutoCloseable telemetry tracking scopes.static final classStores all telemetry related state.static final classAutoCloseable telemetry tracking scope for tool executions. -
Method Summary
Modifier and TypeMethodDescriptionrecordAgentInvocation(InvocationContext ctx, BaseAgent agent) Deprecated.Use the version with explicit parent context instead.recordAgentInvocation(InvocationContext ctx, BaseAgent agent, io.opentelemetry.context.Context parentContext) Creates anInstrumentation.AgentInvocationcontext to record agent invocation telemetry with an explicit parent context.Creates a ToolExecution context to record tool execution telemetry.recordToolExecution(BaseTool tool, BaseAgent agent, Map<String, Object> functionArgs, io.opentelemetry.context.Context parentContext) Creates aInstrumentation.ToolExecutioncontext to record tool execution telemetry with an explicit parent context.
-
Method Details
-
recordAgentInvocation
@Deprecated public static Instrumentation.AgentInvocation recordAgentInvocation(InvocationContext ctx, BaseAgent agent) Deprecated.Use the version with explicit parent context instead. This method will be removed once all callers are updated.Creates an AgentInvocation context to record agent invocation telemetry. -
recordAgentInvocation
public static Instrumentation.AgentInvocation recordAgentInvocation(InvocationContext ctx, BaseAgent agent, io.opentelemetry.context.Context parentContext) Creates anInstrumentation.AgentInvocationcontext to record agent invocation telemetry with an explicit parent context.- Parameters:
ctx- The invocation context of the agent execution.agent- The agent being invoked.parentContext- The OpenTelemetry parent context.- Returns:
- A new
Instrumentation.AgentInvocationscope.
-
recordToolExecution
-
recordToolExecution
public static Instrumentation.ToolExecution recordToolExecution(BaseTool tool, BaseAgent agent, Map<String, Object> functionArgs, io.opentelemetry.context.Context parentContext) Creates aInstrumentation.ToolExecutioncontext to record tool execution telemetry with an explicit parent context.- Parameters:
tool- The tool being executed.agent- The agent invoking the tool.functionArgs- The arguments passed to the tool.parentContext- The OpenTelemetry parent context.- Returns:
- A new
Instrumentation.ToolExecutionscope.
-