类 MetricsUtils
java.lang.Object
io.github.chatpass.dify.util.MetricsUtils
性能监控工具类
- 作者:
- chat-pass
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明static void清空所有统计数据static doublegetAverageResponseTime(String apiName) 获取平均响应时间static longgetErrorCount(String apiName) 获取错误计数static doublegetErrorRate(String apiName) 获取错误率static longgetMaxResponseTime(String apiName) 获取最大响应时间static longgetRequestCount(String apiName) 获取请求计数static voidincrementErrorCount(String apiName) 增加错误计数static voidincrementRequestCount(String apiName) 增加请求计数static void打印所有API的性能统计static voidrecordResponseTime(String apiName, long responseTimeMs) 记录响应时间
-
方法详细资料
-
incrementRequestCount
增加请求计数- 参数:
apiName- API名称
-
incrementErrorCount
增加错误计数- 参数:
apiName- API名称
-
recordResponseTime
记录响应时间- 参数:
apiName- API名称responseTimeMs- 响应时间(毫秒)
-
getRequestCount
获取请求计数- 参数:
apiName- API名称- 返回:
- 请求计数
-
getErrorCount
获取错误计数- 参数:
apiName- API名称- 返回:
- 错误计数
-
getAverageResponseTime
获取平均响应时间- 参数:
apiName- API名称- 返回:
- 平均响应时间(毫秒)
-
getMaxResponseTime
获取最大响应时间- 参数:
apiName- API名称- 返回:
- 最大响应时间(毫秒)
-
getErrorRate
获取错误率- 参数:
apiName- API名称- 返回:
- 错误率(0-1之间)
-
printMetrics
public static void printMetrics()打印所有API的性能统计 -
clearMetrics
public static void clearMetrics()清空所有统计数据
-