Class StatActionInOut

java.lang.Object
com.iohao.net.framework.core.flow.internal.StatActionInOut
All Implemented Interfaces:
ActionMethodInOut

public final class StatActionInOut extends Object implements ActionMethodInOut

PluginInOut - StatActionInOut - Action Call Statistics Plugin

StatActionInOut is an action call statistics plugin that can be used to collect relevant data for each action call, such as the execution count, total time cost, average time cost, maximum time cost, number of exceptions triggered, and other related statistics. Developers can use this data to analyze the hotspot methods and time-consuming methods in the project, thus achieving precise optimization.

// StatAction statistics record print preview
    "StatAction{cmd[1-0], Executed [1] times, Total Time Cost [8], Average Time Cost [8], Maximum Time Cost [8], Exceptions [0] times}"

for example

BarSkeletonBuilder builder = ...;
// Action Call Statistics Plugin, add the plugin to the business framework
var statActionInOut = new StatActionInOut();
builder.addInOut(statActionInOut);

// Set the listener for processing after the StatAction statistics record is updated
statActionInOut.setListener((statAction, time, flowContext) -> {
// Simply print the statistics record value StatAction
    System.out.println(statAction);
});

// Statistics region (manager of statistical values)
StatActionInOut.StatActionRegion region = statActionInOut.getRegion();

// Iterate over all statistics data
region.forEach((cmdInfo, statAction) -> {
// Simply print the statistics record value StatAction
    System.out.println(statAction);
// Developers can periodically save this data to logs or a DB for subsequent analysis
});
Author:
渔民小镇
See Also:
date:
2023-11-17