类: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
用于代理调用的、可自动关闭的遥测数据跟踪功能。
  • 构造函数详细信息

    • 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

      public InvocationContext getCtx()
      检索与此代理调用相关联的调用上下文( invocation context)。
      Returns:
      The InvocationContext.
    • addEvent

      public void addEvent(Event event)
      将一个事件添加到在此次代理调用期间被跟踪的事件列表中。
      Parameters:
      event - The Event to add.
    • recordMetrics

      protected void recordMetrics(Duration elapsed, @Nullable Throwable error)
      记录代理调用的各项指标,包括调用持续时间、请求大小、响应大小以及工作流程中的各个步骤。
      Specified by:
      recordMetrics in class Instrumentation.ClosableTelemetryScope
      Parameters:
      elapsed - The total execution duration.
      error - The exception thrown during execution, if any.
    • handleMetricsError

      protected void handleMetricsError(RuntimeException e)
      用于处理在为代理调用记录指标时发生的错误。
      Specified by:
      handleMetricsError in class Instrumentation.ClosableTelemetryScope
      Parameters:
      e - The runtime exception encountered during metrics recording.