类: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)的基类。
-
字段摘要
FieldsModifier and TypeFieldDescriptionprotected @Nullable Throwable在执行过程中遇到的任何错误(如果有的话)。protected final AtomicBoolean该权限范围是否已被关闭。protected final io.opentelemetry.api.trace.Span与此范围相关联的 OpenTelemetry 跨度(span)。protected final long该范围的开始时间(以纳秒为单位)。protected final Instrumentation.TelemetryContext该范围内的遥测(telemetry)相关信息。 -
方法概述
Modifier and TypeMethodDescriptionprotected void这是一个用于子类的钩子(hook),用于在某个代码段(span)结束之前执行子类中的代码。final voidclose()结束相应的 Span(时间范围),并记录所有相关的指标数据。context()检索与此作用域(scope)相关联的遥测数据(telemetry data)。protected abstract void为子类提供了一个钩子(hook),用于处理与指标记录相关的错误。protected abstract voidrecordMetrics(Duration elapsed, @Nullable Throwable error) 用于让子类记录指标数据的钩子(hook)。void将错误信息记录到相应的 Span 对象中,并将其状态设置为“error”(错误状态)。
-
字段详情
-
startTimeNanos
protected final long startTimeNanos该范围的开始时间(以纳秒为单位)。 -
span
protected final io.opentelemetry.api.trace.Span span与此范围相关联的 OpenTelemetry 跨度(span)。 -
telemetryContext
该范围内的遥测(telemetry)相关信息。 -
caughtError
在执行过程中遇到的任何错误(如果有的话)。 -
closed
该权限范围是否已被关闭。
-
-
方法详细信息(Method Details)
-
context
检索与此作用域(scope)相关联的遥测数据(telemetry data)。- Returns:
- The
Instrumentation.TelemetryContext.
-
setError
将错误信息记录到相应的 Span 对象中,并将其状态设置为“error”(错误状态)。- Parameters:
caughtError- The throwable caught during execution.
-
close
public final void close()结束相应的 Span(时间范围),并记录所有相关的指标数据。- Specified by:
closein interfaceAutoCloseable
-
beforeSpanEnd
protected void beforeSpanEnd()这是一个用于子类的钩子(hook),用于在某个代码段(span)结束之前执行子类中的代码。 -
recordMetrics
-
handleMetricsError
为子类提供了一个钩子(hook),用于处理与指标记录相关的错误。
-