Class NoOpFlowMetrics

java.lang.Object
cloud.opencode.base.flow.observability.NoOpFlowMetrics
All Implemented Interfaces:
FlowMetrics

public final class NoOpFlowMetrics extends Object implements FlowMetrics
Zero-cost default FlowMetrics — every method is an empty body. Used when opencode-base-observability is not on the runtime classpath (or when a host explicitly disables metrics). 零开销 FlowMetrics 默认实现 —— 所有方法为空。 当类路径无 opencode-base-observability(或宿主显式禁用指标)时使用。

The singleton INSTANCE is safe to share across threads.

INSTANCE 单例可跨线程共享。

Since:
JDK 25, opencode-base-flow V1.0.5
Author:
Leon Soo
  • Field Details

    • INSTANCE

      public static final NoOpFlowMetrics INSTANCE
      Shared singleton instance. 共享单例。
      Since:
      JDK 25, opencode-base-flow V1.0.5
  • Constructor Details

    • NoOpFlowMetrics

      public NoOpFlowMetrics()
      Constructs a no-op metrics sink. Prefer the INSTANCE singleton. 构造一个空指标接收器;优先使用 INSTANCE 单例。
      Since:
      JDK 25, opencode-base-flow V1.0.5
  • Method Details

    • recordInstanceStarted

      public void recordInstanceStarted(String flowKey)
      Description copied from interface: FlowMetrics
      Records that a new flow instance has started. 记录一次流程实例启动。
      Specified by:
      recordInstanceStarted in interface FlowMetrics
      Parameters:
      flowKey - business flow key — 业务 key
    • recordInstanceCompleted

      public void recordInstanceCompleted(String flowKey, InstanceStatus finalStatus)
      Description copied from interface: FlowMetrics
      Records that a flow instance has reached a terminal state. 记录一次流程实例达到终态。
      Specified by:
      recordInstanceCompleted in interface FlowMetrics
      Parameters:
      flowKey - business flow key — 业务 key
      finalStatus - the terminal status — 终态状态
    • recordTaskCreated

      public void recordTaskCreated(String flowKey, String stepId)
      Description copied from interface: FlowMetrics
      Records that a PENDING task has been created. 记录一次 PENDING 任务创建。
      Specified by:
      recordTaskCreated in interface FlowMetrics
      Parameters:
      flowKey - business flow key — 业务 key
      stepId - step id — 节点 ID
    • recordTaskCompleted

      public void recordTaskCompleted(String flowKey, String stepId, TaskOutcome outcome)
      Description copied from interface: FlowMetrics
      Records that a task has been completed (approved / rejected / canceled). 记录一次任务完成(同意 / 驳回 / 取消)。
      Specified by:
      recordTaskCompleted in interface FlowMetrics
      Parameters:
      flowKey - business flow key — 业务 key
      stepId - step id — 节点 ID
      outcome - final outcome (nullable when canceled) — 最终结果(取消时为 null)
    • recordOperationDuration

      public void recordOperationDuration(String type, Duration elapsed)
      Description copied from interface: FlowMetrics
      Records the wall-clock elapsed time of a single operation. 记录一次操作的墙钟耗时。
      Specified by:
      recordOperationDuration in interface FlowMetrics
      Parameters:
      type - operation type (start / approve / reject / vote / addSign / withdraw / transfer / circulate / terminate) — 操作类型
      elapsed - elapsed duration — 耗时
    • updateTodoSize

      public void updateTodoSize(int size)
      Description copied from interface: FlowMetrics
      Updates the gauge for the current todo-queue size of an observed user (or aggregate, depending on the host application). A negative value is a sentinel meaning "clear / reset to zero". 更新某用户(或聚合)的当前待办队列大小 gauge。传 -1 表示"清零"。
      Specified by:
      updateTodoSize in interface FlowMetrics
      Parameters:
      size - current size (or -1 to clear) — 当前大小(-1 表示清零)