Class MetricsHook

java.lang.Object
io.agentscope.spring.boot.admin.metrics.MetricsHook
All Implemented Interfaces:
io.agentscope.core.hook.Hook

public final class MetricsHook extends Object implements io.agentscope.core.hook.Hook
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 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 Details

  • Method Details

    • priority

      public int priority()
      Specified by:
      priority in interface io.agentscope.core.hook.Hook
    • onEvent

      public <T extends io.agentscope.core.hook.HookEvent> reactor.core.publisher.Mono<T> onEvent(T event)
      Specified by:
      onEvent in interface io.agentscope.core.hook.Hook