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
用于工具执行的、可自动关闭的遥测数据跟踪功能。
-
字段摘要
Fields inherited from class Instrumentation.ClosableTelemetryScope
caughtError, closed, span, startTimeNanos, telemetryContextModifier and TypeFieldDescriptionprotected @Nullable Throwable在执行过程中遇到的任何错误(如果有的话)。protected final AtomicBoolean该权限范围是否已被关闭。protected final io.opentelemetry.api.trace.Span与此范围相关联的 OpenTelemetry 跨度(span)。protected final long该范围的开始时间(以纳秒为单位)。protected final Instrumentation.TelemetryContext该范围内的遥测(telemetry)相关信息。 -
构造函数概述
Constructors -
方法概述
Modifier and TypeMethodDescriptionprotected void在工具执行完成之前,会记录该工具在执行过程中的各种属性信息(即“span”对象中的数据)。protected void用于处理在为工具执行过程记录指标时发生的错误。protected voidrecordMetrics(Duration elapsed, @Nullable Throwable error) 记录工具执行过程中的各项指标,包括执行时间、请求大小以及响应大小。
-
构造函数详细信息
-
ToolExecution
public ToolExecution(BaseTool tool, BaseAgent agent, Map<String, Object> functionArgs, io.opentelemetry.context.Context parentContext) 构建一个新的……ToolExecution遥测范围(Telemetry 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()在工具执行完成之前,会记录该工具在执行过程中的各种属性信息(即“span”对象中的数据)。- Overrides:
beforeSpanEndin classInstrumentation.ClosableTelemetryScope
-
recordMetrics
记录工具执行过程中的各项指标,包括执行时间、请求大小以及响应大小。- Specified by:
recordMetricsin classInstrumentation.ClosableTelemetryScope- Parameters:
elapsed- The total execution duration.error- The exception thrown during execution, if any.
-
handleMetricsError
用于处理在为工具执行过程记录指标时发生的错误。- Specified by:
handleMetricsErrorin classInstrumentation.ClosableTelemetryScope- Parameters:
e- The runtime exception encountered during metrics recording.
-