MetricsHook
@SuppressWarnings("deprecation") public final class MetricsHook implements Hook
io/agentscope/spring/boot/admin/metrics/MetricsHook.java:40–85指标钩子,承载智能体的部署、调度与服务化运行。位于 io.agentscope.spring.boot.admin.metrics 包,实现 Hook。核心成员包括 priority、onEvent、MetricsHook。
Legacy Hook that observes PostCallEvent and forwards the per-call token usage
to a MetricsRecorder.
The hook is intentionally a non-modifying observer: it never mutates the agent's final
message and always returns the event verbatim, so it is safe to register globally via
io.agentscope.core.agent.AgentBase#addSystemHook(Hook).
Timing caveat: addSystemHook only applies to agents constructed AFTER the
hook is registered (see AgentBase constructor). Agents instantiated before the admin
starter wires this hook in will not contribute to usage stats.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public MetricsHook(MetricsRecorder recorder) | 初始化 `MetricsHook` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public int priority() | 返回优先级。 Returns the priority. |
public T extends HookEvent Mono<T> onEvent(T event) | 处理事件事件。 Performs the on event operation. |
构造器详情Constructor Detail
MetricsHook
public MetricsHook(MetricsRecorder recorder)
初始化 MetricsHook 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
recorder | MetricsRecorder | 记录器(类型 `MetricsRecorder`)。The recorder. |
io/agentscope/spring/boot/admin/metrics/MetricsHook.java:45–47方法详情Method Detail
priority
public int priority()
返回优先级。
Returns the priority.
intio/agentscope/spring/boot/admin/metrics/MetricsHook.java:49–53onEvent
public T extends HookEvent Mono<T> onEvent(T event)
处理事件事件。
Performs the on event operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
event | T | 事件(类型 `T`)。The event. |
Mono<T>io/agentscope/spring/boot/admin/metrics/MetricsHook.java:55–62