AS AgentScopeAPI 手册 / API Reference

MetricsHook

@SuppressWarnings("deprecation") public final class MetricsHook implements Hook
源码Source 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.

参数Parameters
名称Name类型Type说明Description
recorderMetricsRecorder记录器(类型 `MetricsRecorder`)。The recorder.
源码Source io/agentscope/spring/boot/admin/metrics/MetricsHook.java:45–47

方法详情Method Detail

priority

public int priority()

返回优先级。

Returns the priority.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/spring/boot/admin/metrics/MetricsHook.java:49–53

onEvent

public T extends HookEvent Mono<T> onEvent(T event)

处理事件事件。

Performs the on event operation.

参数Parameters
名称Name类型Type说明Description
eventT事件(类型 `T`)。The event.
返回Returns Mono<T>
返回Mono。Returns mono.
源码Source io/agentscope/spring/boot/admin/metrics/MetricsHook.java:55–62

继承成员Inherited Members

继承自Methods inherited from Hook
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.