metrics icon indicating copy to clipboard operation
metrics copied to clipboard

线上使用fastcompass 统计cache命中率时出现很多统计错误

Open bjo2008cnx opened this issue 4 years ago • 3 comments

线上使用fastcompass 统计cache命中率时出现很多统计错误,相应的测试代码如下: public void execute() { long startTime = System.currentTimeMillis(); boolean isSuccess = false; try { TimeUnit.MICROSECONDS.sleep(1000); //do business staff...... //isSuccess = true; } catch (Exception e) { //....... } finally { long endTime = System.currentTimeMillis(); //模拟成功率 isSuccess = startTime % 10 == 0 ? false : true; metric.record(endTime - startTime, isSuccess); } } 这里用的是模拟数据,成功率应在90%。 在单线程下,这段代码输出正确。 在多线程下,线程池数量为100时,抓到的很多数据bucket_count,success_bucket_count,fail_bucket_count,success_rate都为0.0

bjo2008cnx avatar Apr 30 '20 06:04 bjo2008cnx

麻烦提供一下完整的测试用例?

ralf0131 avatar Apr 30 '20 23:04 ralf0131

代码行数比较多,整理后上传到这里了,https://github.com/bjo2008cnx/metrics-examples.git

bjo2008cnx avatar May 07 '20 03:05 bjo2008cnx

麻烦大牛看下,是不是我使用的姿势不对。

bjo2008cnx avatar May 07 '20 03:05 bjo2008cnx