AS AgentScopeAPI 手册 / API Reference

MetricsRecorder

public final class MetricsRecorder
源码Source io/agentscope/spring/boot/admin/metrics/MetricsRecorder.java:30–100

指标记录器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.spring.boot.admin.metrics 包。核心成员包括 record、globalSnapshot、snapshotByAgent、snapshotByModel、reset。

Thread-safe accumulator for token usage counters, sliced by agent name and by model name.

Uses LongAdder so high-concurrency tool/model call paths don't contend on a single AtomicLong. Snapshots are read-side: every read recomputes a frozen UsageStats.

方法摘要Method Summary

方法Method说明Description
public void record(String agentName, String modelName, int inputTokens, int outputTokens)
执行记录相关操作。
Performs the record operation.
public UsageStats globalSnapshot()
返回 `globalSnapshot` 结果。
Returns the global snapshot.
public Map<String, UsageStats> snapshotByAgent()
返回快照通过智能体。
Returns the snapshot by agent.
public Map<String, UsageStats> snapshotByModel()
返回快照通过模型。
Returns the snapshot by model.
public void reset()
清空或重置内部状态。
Test-only — drop all counters.

方法详情Method Detail

record

public void record(String agentName, String modelName, int inputTokens, int outputTokens)

执行记录相关操作。

Performs the record operation.

参数Parameters
名称Name类型Type说明Description
agentNameString智能体名称(类型 `String`)。The agent name.
modelNameString模型名称(类型 `String`)。The model name.
inputTokensint输入令牌数(类型 `int`)。The input tokens.
outputTokensint输出令牌数(类型 `int`)。The output tokens.
源码Source io/agentscope/spring/boot/admin/metrics/MetricsRecorder.java:36–47

globalSnapshot

public UsageStats globalSnapshot()

返回 globalSnapshot 结果。

Returns the global snapshot.

返回Returns UsageStats
返回UsageStats。Returns usage stats.
源码Source io/agentscope/spring/boot/admin/metrics/MetricsRecorder.java:49–51

snapshotByAgent

public Map<String, UsageStats> snapshotByAgent()

返回快照通过智能体。

Returns the snapshot by agent.

返回Returns Map<String, UsageStats>
返回映射。Returns map.
源码Source io/agentscope/spring/boot/admin/metrics/MetricsRecorder.java:53–55

snapshotByModel

public Map<String, UsageStats> snapshotByModel()

返回快照通过模型。

Returns the snapshot by model.

返回Returns Map<String, UsageStats>
返回映射。Returns map.
源码Source io/agentscope/spring/boot/admin/metrics/MetricsRecorder.java:57–59

reset

public void reset()

清空或重置内部状态。

Test-only — drop all counters.

源码Source io/agentscope/spring/boot/admin/metrics/MetricsRecorder.java:62–66
基于官方固定版本源码静态生成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.