类: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
用于代理调用的、可自动关闭的遥测数据跟踪功能。
-
字段摘要
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)相关信息。 -
构造函数概述
ConstructorsConstructorDescriptionAgentInvocation(InvocationContext ctx, BaseAgent agent, io.opentelemetry.context.Context parentContext) 构建一个新的……AgentInvocation遥测范围(Telemetry Scope)。 -
方法概述
Modifier and TypeMethodDescriptionvoid将一个事件添加到在此次代理调用期间被跟踪的事件列表中。getCtx()检索与此代理调用相关联的调用上下文( invocation context)。protected void用于处理在为代理调用记录指标时发生的错误。protected voidrecordMetrics(Duration elapsed, @Nullable Throwable error) 记录代理调用的各项指标,包括调用持续时间、请求大小、响应大小以及工作流程中的各个步骤。Methods inherited from class Instrumentation.ClosableTelemetryScope
beforeSpanEnd, close, context, setError
-
构造函数详细信息
-
AgentInvocation
public AgentInvocation(InvocationContext ctx, BaseAgent agent, io.opentelemetry.context.Context parentContext) 构建一个新的……AgentInvocation遥测范围(Telemetry Scope)。- Parameters:
ctx- The invocation context of the agent execution.agent- The agent being invoked.parentContext- The OpenTelemetry parent context.
-
-
方法详细信息(Method Details)
-
getCtx
检索与此代理调用相关联的调用上下文( invocation context)。- Returns:
- The
InvocationContext.
-
addEvent
-
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.
-