类:Instrumentation.ClosableTelemetryScope

java.lang.Object
com.google.adk.telemetry.Instrumentation.ClosableTelemetryScope
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
Instrumentation.AgentInvocation, Instrumentation.ToolExecution
Enclosing class:
Instrumentation

public abstract static class Instrumentation.ClosableTelemetryScope extends Object implements AutoCloseable
用于实现自动关闭(AutoCloseable)功能的遥测跟踪框架(telemetry tracking framework)的基类。
  • 字段摘要

    Fields
    Modifier and Type
    Field
    Description
    protected @Nullable Throwable
    在执行过程中遇到的任何错误(如果有的话)。
    protected final AtomicBoolean
    该权限范围是否已被关闭。
    protected final io.opentelemetry.api.trace.Span
    与此范围相关联的 OpenTelemetry 跨度(span)。
    protected final long
    该范围的开始时间(以纳秒为单位)。
    该范围内的遥测(telemetry)相关信息。
  • 方法概述

    Modifier and Type
    Method
    Description
    protected void
    这是一个用于子类的钩子(hook),用于在某个代码段(span)结束之前执行子类中的代码。
    final void
    结束相应的 Span(时间范围),并记录所有相关的指标数据。
    检索与此作用域(scope)相关联的遥测数据(telemetry data)。
    protected abstract void
    为子类提供了一个钩子(hook),用于处理与指标记录相关的错误。
    protected abstract void
    recordMetrics(Duration elapsed, @Nullable Throwable error)
    用于让子类记录指标数据的钩子(hook)。
    void
    setError(Throwable caughtError)
    将错误信息记录到相应的 Span 对象中,并将其状态设置为“error”(错误状态)。

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详情

    • startTimeNanos

      protected final long startTimeNanos
      该范围的开始时间(以纳秒为单位)。
    • span

      protected final io.opentelemetry.api.trace.Span span
      与此范围相关联的 OpenTelemetry 跨度(span)。
    • telemetryContext

      protected final Instrumentation.TelemetryContext telemetryContext
      该范围内的遥测(telemetry)相关信息。
    • caughtError

      protected @Nullable Throwable caughtError
      在执行过程中遇到的任何错误(如果有的话)。
    • closed

      protected final AtomicBoolean closed
      该权限范围是否已被关闭。
  • 方法详细信息(Method Details)

    • context

      检索与此作用域(scope)相关联的遥测数据(telemetry data)。
      Returns:
      The Instrumentation.TelemetryContext.
    • setError

      public void setError(Throwable caughtError)
      将错误信息记录到相应的 Span 对象中,并将其状态设置为“error”(错误状态)。
      Parameters:
      caughtError - The throwable caught during execution.
    • close

      public final void close()
      结束相应的 Span(时间范围),并记录所有相关的指标数据。
      Specified by:
      close in interface AutoCloseable
    • beforeSpanEnd

      protected void beforeSpanEnd()
      这是一个用于子类的钩子(hook),用于在某个代码段(span)结束之前执行子类中的代码。
    • recordMetrics

      protected abstract void recordMetrics(Duration elapsed, @Nullable Throwable error)
      用于让子类记录指标数据的钩子(hook)。
    • handleMetricsError

      protected abstract void handleMetricsError(RuntimeException e)
      为子类提供了一个钩子(hook),用于处理与指标记录相关的错误。